List of usage examples for android.widget LinearLayout setDescendantFocusability
public void setDescendantFocusability(int focusability)
From source file:mobisocial.musubi.objects.IntroductionObj.java
@Override public View createView(Context context, ViewGroup frame) { LinearLayout wrap = new LinearLayout(context); wrap.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); wrap.setOrientation(LinearLayout.VERTICAL); wrap.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); wrap.setEnabled(false);//from www.j ava2s.com wrap.setFocusableInTouchMode(false); wrap.setFocusable(false); wrap.setClickable(false); TextView title = new TextView(context); title.setText(R.string.introduced); title.setTypeface(null, Typeface.BOLD); title.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); wrap.addView(title); Gallery intro = new Gallery(context); intro.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); hackGalleryInit(context, intro); wrap.addView(intro); return wrap; }
From source file:org.gots.allotment.adapter.ListAllotmentAdapter.java
@SuppressWarnings("deprecation") @Override//from w w w . j a va 2 s . c om public View getView(final int position, View convertView, ViewGroup parent) { LinearLayout ll = (LinearLayout) convertView; Holder holder; if (ll == null) { holder = new Holder(); ll = (LinearLayout) LayoutInflater.from(mContext).inflate(R.layout.list_allotments, parent, false); if (GotsPreferences.DEBUG) { TextView textView = new TextView(mContext); textView.setText("(" + getItem(position).getId() + ")" + getItem(position).getUUID()); ll.addView(textView); } holder.listSeeds = (GridView) ll.findViewById(R.id.IdGrowingSeedList); holder.titlebar = (LinearLayout) ll.findViewById(R.id.idAllotmentTitlebar); holder.allotmentName = (TextView) ll.findViewById(R.id.textAllotmentName); holder.menu = (LinearLayout) ll.findViewById(R.id.idAllotmentMenu); holder.allotment = getItem(position); ll.setTag(holder); ll.setDescendantFocusability(LinearLayout.FOCUS_BLOCK_DESCENDANTS); // ll.setOnClickListener(this); } else holder = (Holder) ll.getTag(); WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int width; int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) { width = display.getWidth(); } else { Point size = new Point(); display.getSize(size); width = size.x; } int layoutsize = 150; if (width <= 480) layoutsize = 50; int nbcolumn = (width - 200) / layoutsize; if (nbcolumn < 1) nbcolumn = 1; holder.listSeeds.setNumColumns(nbcolumn); listGrowingSeedAdapter = new ListGrowingSeedAdapter(mContext, getItem(position).getSeeds()); holder.listSeeds.setAdapter(listGrowingSeedAdapter); holder.listSeeds.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, layoutsize)); if (listGrowingSeedAdapter.getCount() > 0) { holder.listSeeds.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, (holder.listSeeds.getCount() / nbcolumn + 1) * layoutsize + layoutsize)); // holder.listSeeds.setLayoutParams(new // LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, // LayoutParams.WRAP_CONTENT)); } // else // holder.listSeeds.setLayoutParams(new // LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, // ((holder.listSeeds.getCount() / nbcolumn) + 1) * layoutsize)); holder.allotmentName.setText(getItem(position).getName()); // holder.titlebar.removeAllViews(); holder.menu.setTag(holder); holder.menu.setOnClickListener(this); // SowingAction sow = new SowingAction(mContext); // ActionWidget widget = new ActionWidget(mContext, sow); // widget.setTag(position); if (isSelectable) { holder.menu.setBackgroundResource(R.anim.rotate_alerte); // Animation myFadeInAnimation = // AnimationUtils.loadAnimation(mContext, R.anim.rotate_alerte); // menu.startAnimation(myFadeInAnimation); AnimationDrawable frameAnimation = (AnimationDrawable) holder.menu.getBackground(); frameAnimation.start(); holder.menu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AsyncTask<Void, Integer, GrowingSeedInterface>() { @Override protected GrowingSeedInterface doInBackground(Void... params) { GotsGrowingSeedManager growingSeedManager = GotsGrowingSeedManager.getInstance() .initIfNew(mContext); GotsSeedManager seedManager = GotsSeedManager.getInstance().initIfNew(mContext); // NuxeoGrowingSeedProvider provider = new // NuxeoGrowingSeedProvider(mContext); GrowingSeedInterface growingSeed = (GrowingSeedInterface) seedManager .getSeedById(currentSeedId); growingSeed.setDateSowing(Calendar.getInstance().getTime()); return growingSeedManager.plantingSeed(growingSeed, getItem(position)); } @Override protected void onPostExecute(GrowingSeedInterface seed) { // notifyDataSetChanged(); Toast.makeText(mContext, "Sowing" + " " + SeedUtil.translateSpecie(mContext, seed), Toast.LENGTH_LONG).show(); mContext.sendBroadcast(new Intent(BroadCastMessages.SEED_DISPLAYLIST)); ((Activity) mContext).finish(); } }.execute(); } }); } // widget.setPadding(4, 4, 4, 8); // holder.menu.addView(widget); // // SowingAction sow = new SowingAction(mContext); // ImageView widgetSensor = new ImageView(mContext); // widgetSensor.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_sensor)); // widgetSensor.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.action_selector)); // widgetSensor.setTag(position); // widgetSensor.setOnClickListener(new View.OnClickListener() { // // @Override // public void onClick(View v) { // // GotsPurchaseItem purchaseItem = new GotsPurchaseItem(mContext); // // // if (!purchaseItem.getFeatureParrot() ? true : // purchaseItem.isPremium()) { // if (!purchaseItem.getFeatureParrot() || purchaseItem.isPremium()) { // FragmentManager fm = mContext.getSupportFragmentManager(); // GotsBillingDialog editNameDialog = new // GotsBillingDialog(GotsPurchaseItem.SKU_FEATURE_PARROT); // editNameDialog.setStyle(DialogFragment.STYLE_NORMAL, // R.style.CustomDialog); // editNameDialog.show(fm, "fragment_edit_name"); // } else { // Intent sensorIntent = new Intent(mContext, SensorActivity.class); // mContext.startActivity(sensorIntent); // }// new AsyncTask<Void, Void, List<ParrotLocation>>() { // // private LocationListAdapter sensorListAdapter; // // // // List<ParrotSampleFertilizer> samplesFertilizer = null; // // // // List<ParrotSampleTemperature> samplesTemp = null; // // // // @Override // // protected List<ParrotLocation> doInBackground(Void... params) { // // ParrotSensorProvider sensorProvider = new // ParrotSensorProvider(mContext); // // List<ParrotLocation> locations = sensorProvider.getLocations(); // // sensorProvider.getStatus(); // // samplesFertilizer = // sensorProvider.getSamples(locations.get(0).getLocation_identifier()); // // samplesTemp = // sensorProvider.getSamples2(locations.get(0).getLocation_identifier()); // // // // return locations; // // } // // // // protected void onPostExecute(List<ParrotLocation> result) { // // // sensorListAdapter = new SensorListAdapter(mContext, result); // // sensorListAdapter = new LocationListAdapter(mContext, result); // // // new AlertDialog.Builder(mContext).setAdapter(sensorListAdapter, // // // new DialogInterface.OnClickListener() { // // // // // // @Override // // // public void onClick(DialogInterface dialog, int which) { // // // Toast.makeText(mContext, // sensorListAdapter.getItem(which).getSensor_serial(), // // // Toast.LENGTH_SHORT).show(); // // // ; // // // } // // // }).show(); // // // // Intent sensorIntent = new Intent(mContext, SensorActivity.class); // // mContext.startActivity(sensorIntent); // // // // if (samplesFertilizer != null) { // // WebView webView = new WebView(mContext); // // String chd = new String(); // // for (ParrotSampleFertilizer fertilizer : samplesFertilizer) { // // chd = chd.concat(String.valueOf(fertilizer.getFertilizer_level() * // 100)); // // chd = chd.concat(","); // // } // // chd = chd.substring(0, chd.length() - 1); // // String url = // "http://chart.apis.google.com/chart?cht=ls&chs=250x100&chd=t:" + chd; // // webView.loadUrl(url); // // Log.d(ListAllotmentAdapter.class.getName(), url); // // AlertDialog.Builder alert = new AlertDialog.Builder(mContext); // // alert.setView(webView); // // alert.show(); // // } // // if (samplesTemp != null) { // // WebView webView = new WebView(mContext); // // String chd = new String(); // // int i = 0; // // for (ParrotSampleTemperature sampleTemp : samplesTemp) { // // chd = // chd.concat(String.valueOf(sampleTemp.getAir_temperature_celsius())); // // chd = chd.concat(","); // // if (i++ >= 50) // // break; // // } // // chd = chd.substring(0, chd.length() - 1); // // String url = // "http://chart.apis.google.com/chart?cht=ls&chs=250x100&chd=t:" + chd; // // webView.loadUrl(url); // // Log.d(ListAllotmentAdapter.class.getName(), url); // // AlertDialog.Builder alert = new AlertDialog.Builder(mContext); // // alert.setView(webView); // // alert.show(); // // } // // }; // // }.execute(); // } // }); // // widgetSensor.setPadding(4, 4, 4, 8); // holder.menu.addView(widgetSensor); return ll; }