Example usage for android.widget LinearLayout findViewById

List of usage examples for android.widget LinearLayout findViewById

Introduction

In this page you can find the example usage for android.widget LinearLayout findViewById.

Prototype

@Nullable
public final <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.

Usage

From source file:com.sentaroh.android.Utilities.LogUtil.CommonLogFileListDialogFragment.java

private void setContextButtonListener() {
    LinearLayout ll_prof = (LinearLayout) mDialog.findViewById(R.id.log_context_view);
    ImageButton ib_delete = (ImageButton) ll_prof.findViewById(R.id.log_context_button_delete);
    ImageButton ib_share = (ImageButton) ll_prof.findViewById(R.id.log_context_button_share);
    ImageButton ib_select_all = (ImageButton) ll_prof.findViewById(R.id.log_context_button_select_all);
    ImageButton ib_unselect_all = (ImageButton) ll_prof.findViewById(R.id.log_context_button_unselect_all);
    final ImageButton dlg_done = (ImageButton) mDialog.findViewById(R.id.log_file_list_dlg_done);

    dlg_done.setOnClickListener(new OnClickListener() {
        @Override//from  w w  w.ja va  2s .  co m
        public void onClick(View v) {
            mLogFileManagementAdapter.setAllItemChecked(false);
            mLogFileManagementAdapter.setShowCheckBox(false);
            mLogFileManagementAdapter.notifyDataSetChanged();
            setContextButtonNormalMode(mLogFileManagementAdapter);
        }
    });

    ib_delete.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            confirmDeleteLogFile(mLogFileManagementAdapter);
        }
    });
    ContextButtonUtil.setButtonLabelListener(mContext, ib_delete,
            mContext.getString(R.string.msgs_log_file_list_label_delete));

    ib_share.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            sendLogFile(mLogFileManagementAdapter);
        }
    });
    ContextButtonUtil.setButtonLabelListener(mContext, ib_share,
            mContext.getString(R.string.msgs_log_file_list_label_share));

    ib_select_all.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mLogFileManagementAdapter.setAllItemChecked(true);
            mLogFileManagementAdapter.setShowCheckBox(true);
            setContextButtonSelecteMode(mLogFileManagementAdapter);
        }
    });
    ContextButtonUtil.setButtonLabelListener(mContext, ib_select_all,
            mContext.getString(R.string.msgs_log_file_list_label_select_all));

    ib_unselect_all.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mLogFileManagementAdapter.setAllItemChecked(false);
            //            mLogFileManagementAdapter.setShowCheckBox(false);
            //            setContextButtonNormalMode(mLogFileManagementAdapter);
        }
    });
    ContextButtonUtil.setButtonLabelListener(mContext, ib_unselect_all,
            mContext.getString(R.string.msgs_log_file_list_label_unselect_all));

}

From source file:com.eurotong.orderhelperandroid.OrderMenuActivity.java

private void AddOrder(View v, int orderCount) {
    VMMenulistOrder menu = (VMMenulistOrder) v.getTag();
    LinearLayout viewParent = (LinearLayout) v.getParent();

    //TextView viewMenuNr=(TextView)viewParent.findViewById(R.id.txtOrderMenuNr);
    //String menuNr=viewMenuNr.getText().toString();   
    TextView viewOrderCount = (TextView) viewParent.findViewById(R.id.txtOrderCount);
    if (menu != null) {
        try {/*from   w ww.  j a va 2  s . c  o  m*/
            menu.OrderCount += orderCount;
            if (menu.OrderCount < 0) {
                menu.OrderCount = 0;
            }
            viewOrderCount.setText(Common.FormatDoubleToNoDecimal(menu.OrderCount));
            SetStyleForOrderedMenu(menu, viewOrderCount);

            SaveTableOrders();

            FillHeaderView();

            //clear input text
            SetEditTextInputText("");

        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            Log.e(Define.APP_CATALOG, e.toString());
        }
    }
}

From source file:ch.teamuit.android.soundplusplus.LibraryActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_SEARCH:
        mBottomBarControls.showSearch(true);
        return true;
    case MENU_PLAYBACK:
        openPlaybackActivity();/*from ww  w  .ja  v  a  2 s .  c  o m*/
        return true;
    case MENU_SORT: {
        MediaAdapter adapter = (MediaAdapter) mCurrentAdapter;
        LinearLayout header = (LinearLayout) getLayoutInflater().inflate(R.layout.sort_dialog, null);
        CheckBox reverseSort = (CheckBox) header.findViewById(R.id.reverse_sort);

        int[] itemIds = adapter.getSortEntries();
        String[] items = new String[itemIds.length];
        Resources res = getResources();
        for (int i = itemIds.length; --i != -1;) {
            items[i] = res.getString(itemIds[i]);
        }

        int mode = adapter.getSortMode();
        if (mode < 0) {
            mode = ~mode;
            reverseSort.setChecked(true);
        }

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.sort_by);
        builder.setSingleChoiceItems(items, mode + 1, this); // add 1 for header
        builder.setNeutralButton(R.string.done, null);

        AlertDialog dialog = builder.create();
        dialog.getListView().addHeaderView(header);
        dialog.setOnDismissListener(this);
        dialog.show();
        return true;
    }
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:org.gots.allotment.adapter.ListAllotmentAdapter.java

@SuppressWarnings("deprecation")
@Override/*from w  w  w .jav  a 2 s. c o m*/
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;
}

From source file:com.example.zf_android.trade.ApplyDetailActivity.java

private void setItemValue(Object key, String value) {
    LinearLayout item = (LinearLayout) mContainer.findViewWithTag(key);
    TextView tvValue = (TextView) item.findViewById(R.id.apply_detail_value);
    tvValue.setText(value);//from  w w  w  .j  ava  2s .  c  o m
}

From source file:com.example.zf_android.trade.ApplyDetailActivity.java

/**
 * set the item value by key//from w  w w . j a  va 2 s  .c  o m
 *
 * @param key
 * @param value
 */
private void setItemValue(String key, String value) {
    LinearLayout item = (LinearLayout) mContainer.findViewWithTag(key);
    TextView tvValue = (TextView) item.findViewById(R.id.apply_detail_value);
    tvValue.setText(value);
}

From source file:com.example.zf_android.trade.ApplyDetailActivity.java

/**
* get the item value by key/* w  w w .ja  v  a  2  s.com*/
*
* @param key
* @return
*/
private String getItemValue(Object key) {
    LinearLayout item = (LinearLayout) mContainer.findViewWithTag(key);
    TextView tvValue = (TextView) item.findViewById(R.id.apply_detail_value);
    return tvValue.getText().toString();
}

From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case MENU_SEARCH:
        mBottomBarControls.showSearch(true);
        break;/*from w  w w. j  a  va 2  s  .c om*/
    case MENU_PLAYBACK:
        openPlaybackActivity();
        break;
    case MENU_GO_HOME:
        mPagerAdapter.setLimiter(FileSystemAdapter.buildHomeLimiter(getApplicationContext()));
        updateLimiterViews();
        break;
    case MENU_SORT: {
        SortableAdapter adapter = (SortableAdapter) mCurrentAdapter;
        LinearLayout list = (LinearLayout) getLayoutInflater().inflate(R.layout.sort_dialog, null);
        CheckBox reverseSort = (CheckBox) list.findViewById(R.id.reverse_sort);

        int[] itemIds = adapter.getSortEntries();
        String[] items = new String[itemIds.length];
        Resources res = getResources();
        for (int i = 0; i < itemIds.length; i++) {
            items[i] = res.getString(itemIds[i]);
        }

        int mode = adapter.getSortModeIndex();
        reverseSort.setChecked(adapter.isSortDescending());

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.sort_by);
        builder.setSingleChoiceItems(items, mode, this);
        builder.setPositiveButton(R.string.done, null);

        AlertDialog dialog = builder.create();
        dialog.getListView().addFooterView(list);
        dialog.setOnDismissListener(this);
        dialog.show();
        break;
    }
    default:
        return super.onOptionsItemSelected(item);
    }
    return true;
}

From source file:org.matrix.console.activity.SettingsActivity.java

private void saveChanges(final MXSession session) {
    LinearLayout linearLayout = mLinearLayoutByMatrixId.get(session.getCredentials().userId);

    final String nameFromForm = getEditedUserName(session);
    final ApiCallback<Void> changeCallback = UIUtils.buildOnChangeCallback(this);

    final MyUser myUser = session.getMyUser();
    final Button saveButton = (Button) linearLayout.findViewById(R.id.button_save);

    // disable the save button to avoid unexpected behaviour
    saveButton.setEnabled(false);//from  w  w  w  .j  a va  2  s  .co  m

    if (UIUtils.hasFieldChanged(myUser.displayname, nameFromForm)) {
        myUser.updateDisplayName(nameFromForm, new SimpleApiCallback<Void>(changeCallback) {
            @Override
            public void onSuccess(Void info) {
                super.onSuccess(info);
                updateSaveButton(saveButton);
            }
        });
    }

    Uri newAvatarUri = mTmpThumbnailUriByMatrixId.get(session.getCredentials().userId);

    if (newAvatarUri != null) {
        Log.d(LOG_TAG, "Selected image to upload: " + newAvatarUri);
        ResourceUtils.Resource resource = ResourceUtils.openResource(this, newAvatarUri);
        if (resource == null) {
            Toast.makeText(SettingsActivity.this, getString(R.string.settings_failed_to_upload_avatar),
                    Toast.LENGTH_LONG).show();
            return;
        }

        final ProgressDialog progressDialog = ProgressDialog.show(this, null,
                getString(R.string.message_uploading), true);

        session.getContentManager().uploadContent(resource.contentStream, null, resource.mimeType, null,
                new ContentManager.UploadCallback() {

                    @Override
                    public void onUploadStart(String uploadId) {
                    }

                    @Override
                    public void onUploadProgress(String anUploadId, int percentageProgress) {
                        progressDialog.setMessage(
                                getString(R.string.message_uploading) + " (" + percentageProgress + "%)");
                    }

                    @Override
                    public void onUploadComplete(String anUploadId, ContentResponse uploadResponse,
                            final int serverResponseCode, String serverErrorMessage) {
                        if (uploadResponse == null) {
                            Toast.makeText(SettingsActivity.this,
                                    (null != serverErrorMessage) ? serverErrorMessage
                                            : getString(R.string.settings_failed_to_upload_avatar),
                                    Toast.LENGTH_LONG).show();
                        } else {
                            Log.d(LOG_TAG, "Uploaded to " + uploadResponse.contentUri);
                            myUser.updateAvatarUrl(uploadResponse.contentUri,
                                    new SimpleApiCallback<Void>(changeCallback) {
                                        @Override
                                        public void onSuccess(Void info) {
                                            super.onSuccess(info);
                                            // Reset this because its being set is how we know there's been a change
                                            mTmpThumbnailUriByMatrixId.remove(session.getCredentials().userId);
                                            updateSaveButton(saveButton);
                                        }
                                    });
                        }
                        progressDialog.dismiss();
                    }
                });
    }
}

From source file:com.friedran.appengine.dashboard.gui.DashboardLoadFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.load_fragment, container, false);

    mActivity = (DashboardActivity) getSherlockActivity();

    setSpinnerWithItems(layout, R.array.load_time_options, R.id.load_chart_time_spinner);
    mDisplayedTimeID = 0;//from w w w.j ava  2  s.c  om

    mDisplayMetrics = new DisplayMetrics();
    mActivity.getWindowManager().getDefaultDisplay().getMetrics(mDisplayMetrics);

    Account account = getArguments().getParcelable(KEY_ACCOUNT);
    String applicationID = getArguments().getString(KEY_APPLICATION_ID);
    mChartGridAdapter = new ChartAdapter(mActivity, AppEngineDashboardAPI.getInstance().getClient(account),
            applicationID);

    GridView chartsGridView = (GridView) layout.findViewById(R.id.load_charts_grid);
    chartsGridView.setAdapter(mChartGridAdapter);

    mChartsMemoryCache = initChartsMemoryCache();

    mTracker = AnalyticsUtils.getTracker(mActivity);

    mPullToRefreshAttacher = mActivity.getPullToRefreshAttacher();
    mPullToRefreshAttacher.setRefreshableView(chartsGridView, this);

    return layout;
}