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:org.mklab.mikity.android.FileSelectionFragment.java

/**
 * ???????// w  w w . ja  va 2  s.c  om
 * 
 * @param mainView
 */
private void createSourceComponent(View mainView) {
    final List<GroupModel> rootGroups = this.canvasFragment.root.getScene(0).getGroups();
    final Set<String> sourceIds = getAllSourceIds(rootGroups);

    final LinearLayout sources = (LinearLayout) mainView.findViewById(R.id.layout_sources);
    sources.removeAllViews();

    this.sourceSelectButtons.clear();
    this.sourceReloadButtons.clear();
    this.sourceFileNameViews.clear();

    for (final String sourceId : sourceIds) {
        final LinearLayout source = (LinearLayout) FileSelectionFragment.this.mainActivity.getLayoutInflater()
                .inflate(R.layout.source, null);
        sources.addView(source);

        final Button selectButton = (Button) source.findViewById(R.id.sourceSelectButton);
        selectButton.setText(getString(R.string.source) + "(" + sourceId + ")"); //$NON-NLS-1$ //$NON-NLS-2$
        this.sourceSelectButtons.add(selectButton);

        selectButton.setOnClickListener(new View.OnClickListener() {
            /**
             * {@inheritDoc}
             */
            public void onClick(View view) {
                FileSelectionFragment.this.mainActivity.sendFileChooseIntentForLoadingSource(sourceId);
            }
        });

        final TextView fileNameView = (TextView) source.findViewById(R.id.sourceFileNameView);
        if (this.sourceFileNames.containsKey(sourceId)) {
            fileNameView.setText(this.sourceFileNames.get(sourceId));
        }
        this.sourceFileNameViews.put(sourceId, fileNameView);

        final Button reloadButton = (Button) source.findViewById(R.id.sourceReloadButton);
        this.sourceReloadButtons.add(reloadButton);

        reloadButton.setOnClickListener(new View.OnClickListener() {

            /**
             * {@inheritDoc}
             */
            public void onClick(View view) {
                if (FileSelectionFragment.this.canvasFragment.sourceData.containsKey(sourceId)) {
                    FileSelectionFragment.this.canvasFragment.addSource(sourceId);
                }
            }
        });
    }

}

From source file:com.nadmm.airports.FragmentBase.java

protected View addRow(LinearLayout layout, String label, String value1, String value2) {
    if (layout.getChildCount() > 0) {
        addSeparator(layout);/*from  w  w w  . j av  a  2 s . com*/
    }

    LinearLayout row = (LinearLayout) inflate(R.layout.detail_row_item3);
    TextView tv = (TextView) row.findViewById(R.id.item_label);
    tv.setText(label);
    tv = (TextView) row.findViewById(R.id.item_value);
    if (value1 != null && value1.length() > 0) {
        tv.setText(value1);
    } else {
        tv.setVisibility(View.GONE);
    }
    tv = (TextView) row.findViewById(R.id.item_extra_value);
    if (value2 != null && value2.length() > 0) {
        tv.setText(value2);
    } else {
        tv.setVisibility(View.GONE);
    }
    layout.addView(row, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    return row;
}

From source file:de.dmxcontrol.fragment.PanelSelectorFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        mActiveInputType = savedInstanceState.getInt(EXTRA_ACTIVE_INPUT_TYPE, ACTIVE_INPUT_TYPE_DEVICE);
    } else {/*from w  w  w.  j  a va2 s  .com*/
        mActiveInputType = ACTIVE_INPUT_TYPE_DEVICE;
    }

    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.group_device_selector_fragment, container,
            false);
    mEntitySelection = EntityManager.get().getEntitySelection(EntityManager.CENTRAL_ENTITY_SELECTION);
    mEntitySelection.addListener(this);

    mEditDevice = (EditText) layout.findViewById(R.id.device_input);
    mEditDevice.setInputType(InputType.TYPE_NULL);
    mEditDevice.setText(mEntitySelection.getRangesString(Type.DEVICE));

    mEditGroup = (EditText) layout.findViewById(R.id.group_input);
    mEditGroup.setInputType(InputType.TYPE_NULL);
    mEditGroup.setText(mEntitySelection.getRangesString(Type.GROUP));

    mBDevice = (Button) layout.findViewById(R.id.button_dev);
    mBDevice.setOnClickListener(this);

    updateActiveInputType();

    Button bSpan = (Button) layout.findViewById(R.id.button_span);
    bSpan.setOnClickListener(this);
    Button bAggregate = (Button) layout.findViewById(R.id.button_aggregate);
    bAggregate.setOnClickListener(this);
    Button bStar = (Button) layout.findViewById(R.id.button_star);
    bStar.setOnClickListener(this);

    Button bErase = (Button) layout.findViewById(R.id.button_clear);
    bErase.setOnClickListener(this);
    bErase.setOnLongClickListener(this);

    Button bOne = (Button) layout.findViewById(R.id.button_one);
    bOne.setOnClickListener(this);
    Button bTwo = (Button) layout.findViewById(R.id.button_two);
    bTwo.setOnClickListener(this);
    Button bThree = (Button) layout.findViewById(R.id.button_three);
    bThree.setOnClickListener(this);
    Button bFour = (Button) layout.findViewById(R.id.button_four);
    bFour.setOnClickListener(this);
    Button bFive = (Button) layout.findViewById(R.id.button_five);
    bFive.setOnClickListener(this);
    Button bSix = (Button) layout.findViewById(R.id.button_six);
    bSix.setOnClickListener(this);
    Button bSeven = (Button) layout.findViewById(R.id.button_seven);
    bSeven.setOnClickListener(this);
    Button bEight = (Button) layout.findViewById(R.id.button_eight);
    bEight.setOnClickListener(this);
    Button bNine = (Button) layout.findViewById(R.id.button_nine);
    bNine.setOnClickListener(this);
    Button bZero = (Button) layout.findViewById(R.id.button_zero);
    bZero.setOnClickListener(this);

    return layout;
}

From source file:com.nadmm.airports.FragmentBase.java

protected View addRow(LinearLayout layout, String label1, String value1, String label2, String value2) {
    if (layout.getChildCount() > 0) {
        addSeparator(layout);/*from www .ja  va 2 s.  c  o  m*/
    }

    LinearLayout row = (LinearLayout) inflate(R.layout.detail_row_item4);
    TextView tv = (TextView) row.findViewById(R.id.item_label);
    tv.setText(label1);
    tv = (TextView) row.findViewById(R.id.item_value);
    if (value1 != null && value1.length() > 0) {
        tv.setText(value1);
    } else {
        tv.setVisibility(View.GONE);
    }
    tv = (TextView) row.findViewById(R.id.item_extra_label);
    if (label2 != null && label2.length() > 0) {
        tv.setText(label2);
    } else {
        tv.setVisibility(View.GONE);
    }
    tv = (TextView) row.findViewById(R.id.item_extra_value);
    if (value2 != null && value2.length() > 0) {
        tv.setText(value2);
    } else {
        tv.setVisibility(View.GONE);
    }
    layout.addView(row, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    return row;
}

From source file:com.esri.android.mapsapp.MapsAppActivity.java

/**
 * Updates the navigation drawer items./*w ww  . ja  va2s  .  co m*/
 */
private void updateDrawer() {
    mDrawerItems.clear();

    DrawerItem item;
    if (AccountManager.getInstance().isSignedIn()) {

        // user info
        LinearLayout userInfoView = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_user_layout,
                null);
        TextView textView = (TextView) userInfoView.findViewById(R.id.drawer_item_fullname_textview);
        textView.setText(AccountManager.getInstance().getPortalUser().getFullName());

        textView = (TextView) userInfoView.findViewById(R.id.drawer_item_username_textview);
        textView.setText(AccountManager.getInstance().getPortalUser().getUsername());

        item = new DrawerItem(userInfoView, null);
        mDrawerItems.add(item);

        // Sign Out

        LinearLayout view_signOut = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_layout,
                null);
        TextView text_drawer_signOut = (TextView) view_signOut.findViewById(R.id.drawer_item_textview);
        ImageView icon_drawer_signOut = (ImageView) view_signOut.findViewById(R.id.drawer_item_icon);

        text_drawer_signOut.setText(getString(R.string.sign_out));
        icon_drawer_signOut.setImageResource(R.drawable.ic_profile);
        item = new DrawerItem(view_signOut, new DrawerItem.OnClickListener() {

            @Override
            public void onClick() {
                signOut();
            }
        });
        mDrawerItems.add(item);

        // My Maps
        LinearLayout view_myMaps = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_layout,
                null);
        TextView text_drawer_myMaps = (TextView) view_myMaps.findViewById(R.id.drawer_item_textview);
        ImageView icon_drawer_myMaps = (ImageView) view_myMaps.findViewById(R.id.drawer_item_icon);

        text_drawer_myMaps.setText(getString(R.string.my_maps));
        icon_drawer_myMaps.setImageResource(R.drawable.ic_map32);
        item = new DrawerItem(view_myMaps, new DrawerItem.OnClickListener() {

            @Override
            public void onClick() {
                showContentBrowser();
            }
        });
        mDrawerItems.add(item);
    } else {

        // Adding the Sign In item in the drawer
        LinearLayout view_signIn = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_layout,
                null);
        TextView text_drawer_signIn = (TextView) view_signIn.findViewById(R.id.drawer_item_textview);
        ImageView icon_drawer_signIn = (ImageView) view_signIn.findViewById(R.id.drawer_item_icon);

        text_drawer_signIn.setText(getString(R.string.sign_in));
        icon_drawer_signIn.setImageResource(R.drawable.ic_profile);
        item = new DrawerItem(view_signIn, new DrawerItem.OnClickListener() {

            @Override
            public void onClick() {
                showSignInActivity();
            }
        });
        mDrawerItems.add(item);
    }

    // Adding the basemap item in the drawer
    LinearLayout view_basemap = (LinearLayout) getLayoutInflater().inflate(R.layout.drawer_item_layout, null);
    TextView text_drawer_basemap = (TextView) view_basemap.findViewById(R.id.drawer_item_textview);
    ImageView icon_drawer_basemap = (ImageView) view_basemap.findViewById(R.id.drawer_item_icon);
    text_drawer_basemap.setText(getString(R.string.menu_basemaps));
    icon_drawer_basemap.setImageResource(R.drawable.action_basemaps);
    item = new DrawerItem(view_basemap, new DrawerItem.OnClickListener() {

        @Override
        public void onClick() {
            // Show BasemapsDialogFragment to offer a choice if basemaps.
            // This calls back to onBasemapChanged() if one is selected.
            BasemapsDialogFragment basemapsFrag = new BasemapsDialogFragment();
            basemapsFrag.setBasemapsDialogListener(new BasemapsDialogFragment.BasemapsDialogListener() {

                @Override
                public void onBasemapChanged(String itemId) {
                    showMap(null, itemId);
                }
            });
            basemapsFrag.show(getFragmentManager(), null);
            mDrawerLayout.closeDrawers();
        }

    });

    mDrawerItems.add(item);

    BaseAdapter adapter = (BaseAdapter) mDrawerList.getAdapter();
    if (adapter == null) {
        adapter = new DrawerItemListAdapter();
        mDrawerList.setAdapter(adapter);
    } else {
        adapter.notifyDataSetChanged();
    }
}

From source file:com.gh4a.activities.SearchActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.generic_list);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle(R.string.search);

    LayoutInflater inflater = LayoutInflater.from(UiUtils.makeHeaderThemedContext(this));
    LinearLayout searchLayout = (LinearLayout) inflater.inflate(R.layout.search_action_bar, null);
    actionBar.setCustomView(searchLayout);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

    mSearchType = (Spinner) searchLayout.findViewById(R.id.search_type);
    mSearchType.setAdapter(new SearchTypeAdapter(actionBar.getThemedContext(), this));
    mSearchType.setOnItemSelectedListener(this);

    mSearch = (SearchView) searchLayout.findViewById(R.id.search_view);
    mSearch.setIconifiedByDefault(true);
    mSearch.requestFocus();//ww w .ja v  a  2 s  . c om
    mSearch.setIconified(false);
    mSearch.setOnQueryTextListener(this);
    mSearch.setOnCloseListener(this);
    mSearch.onActionViewExpanded();

    updateSelectedSearchType();

    mResultsView = (RecyclerView) findViewById(R.id.list);
    mResultsView.setLayoutManager(new LinearLayoutManager(this));
    mResultsView.addItemDecoration(new DividerItemDecoration(this));

    if (savedInstanceState != null) {
        mQuery = savedInstanceState.getString(STATE_KEY_QUERY);
        mSearch.setQuery(mQuery, false);

        LoaderManager lm = getSupportLoaderManager();
        int previousMode = savedInstanceState.getInt(STATE_KEY_SEARCH_MODE, SEARCH_MODE_NONE);
        switch (previousMode) {
        case SEARCH_MODE_REPO:
            lm.initLoader(0, null, mRepoCallback);
            break;
        case SEARCH_MODE_USER:
            lm.initLoader(0, null, mUserCallback);
            break;
        case SEARCH_MODE_CODE:
            lm.initLoader(0, null, mCodeCallback);
            break;
        }
    }
}

From source file:com.example.android.wearable.quiz.MainActivity.java

/**
 * Updates the given question based on whether it was answered correctly or not.
 * This involves changing the question's text color and changing the status text for it.
 *//*from   ww w . j  av  a2  s  . c o m*/
public void updateQuestionStatus(int questionIndex, boolean questionCorrect) {
    LinearLayout questionStatusElement = (LinearLayout) questionsContainer.getChildAt(questionIndex);
    TextView questionText = (TextView) questionStatusElement.findViewById(R.id.question);
    TextView questionStatus = (TextView) questionStatusElement.findViewById(R.id.status);
    if (questionCorrect) {
        questionText.setTextColor(Color.GREEN);
        questionStatus.setText(R.string.question_correct);
        mNumCorrect++;
    } else {
        questionText.setTextColor(Color.RED);
        questionStatus.setText(R.string.question_incorrect);
        mNumIncorrect++;
    }
}

From source file:project.pamela.slambench.fragments.RankPlot.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Replace LinearLayout by the type of the root element of the layout you're trying to load
    LinearLayout llLayout = (LinearLayout) inflater.inflate(R.layout.rank_plot, container, false);

    TextView oclLegend = (TextView) llLayout.findViewById(R.id.oclLegend);
    TextView cppLegend = (TextView) llLayout.findViewById(R.id.cppLegend);
    TextView otherLegend = (TextView) llLayout.findViewById(R.id.otherLegend);
    TextView yoursLegend = (TextView) llLayout.findViewById(R.id.yoursLegend);

    oclLegend.setBackgroundColor(getResources().getColor(R.color.oclLegendColor));
    cppLegend.setBackgroundColor(getResources().getColor(R.color.cppLegendColor));
    otherLegend.setBackgroundColor(getResources().getColor(R.color.othersLegendColor));
    yoursLegend.setBackgroundColor(getResources().getColor(R.color.yoursLegendColor));

    /*//  www  . ja  va 2  s  .c  om
    if (SLAMBenchApplication.getBenchmark() == null) {
    // Need to run the configuration download ....
    try {
        InputStream inputStream = this.getActivity().getAssets().open("demo.xml");
        SLAMBenchXmlParser parser = new SLAMBenchXmlParser();
        SLAMConfiguration entries = parser.parse(inputStream);
        inputStream.close();
        SLAMBenchApplication.setBenchmark(new SLAMBench(entries));
        if (entries == null ) {
            Log.e(SLAMBenchApplication.LOG_TAG, getString(R.string.log_configuration_error));
        }
    } catch (IOException e) {
        Log.e(SLAMBenchApplication.LOG_TAG, getString(R.string.log_configuration_error), e);
    } catch (XmlPullParserException e) {
        Log.e(SLAMBenchApplication.LOG_TAG, getString(R.string.log_configuration_error), e);
    }
            
    }
    */

    if (SLAMBenchApplication.getBenchmark() == null) {
        return llLayout;
    }

    List<SLAMRank> ranks = SLAMBenchApplication.getBenchmark().getDevicesRank();

    values = new Double[ranks.size() + 1];
    devices = new String[ranks.size() + 1];
    versions = new String[ranks.size() + 1];

    for (int i = 0; i < ranks.size(); i++) {
        SLAMRank r = ranks.get(i);
        values[i] = r.get_result();
        devices[i] = r.get_device();

        versions[i] = (r.get_test() == null) ? "" : r.get_test().name;
    }

    double best = SLAMBenchApplication.getBenchmark().getBestSpeed();

    values[values.length - 1] = (best <= 0) ? 0 : 1.0 / best;
    devices[values.length - 1] = YOUR_DEVICE;
    if (SLAMBenchApplication.getBenchmark() != null
            && SLAMBenchApplication.getBenchmark().getBestResult() != null
            && SLAMBenchApplication.getBenchmark().getBestResult().test != null) {
        versions[values.length - 1] = SLAMBenchApplication.getBenchmark().getBestResult().test.name;
    } else {
        versions[values.length - 1] = "";
    }
    for (int n = 0; n < values.length; n++) {
        for (int m = 0; m < values.length - 1 - n; m++) {
            if ((values[m].compareTo(values[m + 1])) <= 0) {
                String swapString = devices[m];
                devices[m] = devices[m + 1];
                devices[m + 1] = swapString;
                swapString = versions[m];
                versions[m] = versions[m + 1];
                versions[m + 1] = swapString;
                Double swapInt = values[m];
                values[m] = values[m + 1];
                values[m + 1] = swapInt;
            }
        }
    }

    int start = Math.max(0, values.length - RANK_SIZE - 1);
    int end = values.length - 1;

    Log.d(SLAMBenchApplication.LOG_TAG,
            "Default ArrayOfRange(" + Integer.valueOf(start) + "," + Integer.valueOf(end) + ")");

    for (int i = 0; i < values.length; i++) {
        if (devices[i].equals(YOUR_DEVICE)) {
            start = Math.max(0, i - (RANK_SIZE / 2));
            end = Math.min(values.length - 1, start + RANK_SIZE);
            if (end - start < RANK_SIZE) {
                start = Math.max(0, end - RANK_SIZE);
            }
            break;
        }
    }

    Log.d(SLAMBenchApplication.LOG_TAG,
            "ArrayOfRange(" + Integer.valueOf(start) + "," + Integer.valueOf(end) + ")");

    if (best > 0) {
        values = Arrays.copyOfRange(values, start, end);
        devices = Arrays.copyOfRange(devices, start, end);
        versions = Arrays.copyOfRange(versions, start, end);
    } else {
        values = Arrays.copyOf(values, values.length - 1);
        devices = Arrays.copyOf(devices, devices.length - 1);
        versions = Arrays.copyOf(versions, versions.length - 1);
    }
    // initialize our XYPlot reference:
    plot = (XYPlot) llLayout.findViewById(R.id.mySimpleXYPlot);

    // colors
    plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);
    plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);
    plot.getBorderPaint().setColor(Color.WHITE);
    plot.getBackgroundPaint().setColor(Color.WHITE);
    plot.getGraphWidget().getDomainLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeLabelPaint().setTextSize(20);
    plot.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);
    plot.getGraphWidget().getDomainGridLinePaint().setColor(Color.TRANSPARENT);
    //plot.getGraphWidget().getRangeGridLinePaint().setColor(Color.TRANSPARENT);

    formatter1 = new MyBarFormatter(getResources().getColor(R.color.othersLegendColor), Color.WHITE);
    openclFormatter = new MyBarFormatter(getResources().getColor(R.color.oclLegendColor), Color.WHITE);
    cppFormatter = new MyBarFormatter(getResources().getColor(R.color.cppLegendColor), Color.WHITE);
    currentFormatter = new MyBarFormatter(getResources().getColor(R.color.yoursLegendColor), Color.WHITE);

    plot.setTicksPerRangeLabel(1);

    //plot.getLayoutManager().remove(plot.getLegendWidget());
    plot.getLayoutManager().remove(plot.getTitleWidget());
    plot.getLayoutManager().remove(plot.getDomainLabelWidget());
    plot.getLayoutManager().remove(plot.getRangeLabelWidget());

    plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 0.5);

    plot.getGraphWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_LEFT, 0, YLayoutStyle.ABSOLUTE_FROM_BOTTOM,
            AnchorPosition.LEFT_BOTTOM);

    plot.getGraphWidget().setSize(new SizeMetrics(0, SizeLayoutType.FILL, 0, SizeLayoutType.FILL));

    plot.setDomainValueFormat(new NumberFormat() {
        @Override
        public StringBuffer format(double value, StringBuffer buffer, FieldPosition field) {
            int index = (int) (value);
            //if ((index) == (value)) {
            //    return new StringBuffer(devices[index]);
            //}
            return new StringBuffer("");
        }

        @Override
        public StringBuffer format(long value, StringBuffer buffer, FieldPosition field) {
            throw new UnsupportedOperationException("Not yet implemented.");
        }

        @Override
        public Number parse(String string, ParsePosition position) {
            throw new UnsupportedOperationException("Not yet implemented.");
        }
    });

    // Setup our Series with the selected number of elements
    series1 = new SimpleXYSeries(Arrays.asList(values), SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, "devices");

    // add a new series' to the xyplot:
    plot.addSeries(series1, formatter1);

    // Setup the BarRenderer with our selected options
    MyBarRenderer renderer = ((MyBarRenderer) plot.getRenderer(MyBarRenderer.class));
    renderer.setBarRenderStyle(BarRenderer.BarRenderStyle.OVERLAID);
    renderer.setBarWidthStyle(BarRenderer.BarWidthStyle.VARIABLE_WIDTH);
    renderer.setBarWidth(BAR_GAP);
    renderer.setBarGap(BAR_GAP);
    plot.getGraphWidget().setDomainLabelOrientation(-90);

    plot.getGraphWidget().setGridPaddingRight(0);
    plot.getGraphWidget().setGridPaddingTop(0);
    plot.getGraphWidget().setGridPaddingLeft(0);
    plot.getGraphWidget().setGridPaddingBottom(0);

    plot.calculateMinMaxVals();

    PointF minXY = new PointF(plot.getCalculatedMinX().floatValue(), plot.getCalculatedMinY().floatValue());
    PointF maxXY = new PointF(plot.getCalculatedMaxX().floatValue(), plot.getCalculatedMaxY().floatValue());

    plot.setDomainBoundaries(minXY.x - 0.5, maxXY.x + 0.5, BoundaryMode.FIXED);
    plot.setRangeBoundaries(0, (int) (maxXY.y / 10) * 10f + 10f, BoundaryMode.FIXED);

    plot.redraw();

    return llLayout;
}

From source file:org.mitre.svmp.activities.SvmpActivity.java

protected void passwordChangePrompt(final ConnectionInfo connectionInfo) {
    // if this connection uses password authentication, proceed
    if ((connectionInfo.getAuthType() & PasswordModule.AUTH_MODULE_ID) == PasswordModule.AUTH_MODULE_ID) {

        // the service is running for this connection, stop it so we can re-authenticate
        if (SessionService.isRunningForConn(connectionInfo.getConnectionID()))
            stopService(new Intent(SvmpActivity.this, SessionService.class));

        // create the input container
        final LinearLayout inputContainer = (LinearLayout) getLayoutInflater().inflate(R.layout.auth_prompt,
                null);/* w  w  w .  j  a  va  2 s .c  om*/

        // set the message
        TextView message = (TextView) inputContainer.findViewById(R.id.authPrompt_textView_message);
        message.setText(connectionInfo.getUsername());

        final HashMap<IAuthModule, View> moduleViewMap = new HashMap<IAuthModule, View>();
        // populate module view map, add input views for each required auth module
        // (we know at least password input is required)
        addAuthModuleViews(connectionInfo, moduleViewMap, inputContainer);

        // loop through the Auth module(s) to find the View for the old password input (needed for validation)
        View oldPasswordView = null;
        for (Map.Entry<IAuthModule, View> entry : moduleViewMap.entrySet()) {
            if (entry.getKey().getID() == PasswordModule.AUTH_MODULE_ID) {
                oldPasswordView = entry.getValue();
                break;
            }
        }

        // add "new password" and "confirm new password" views
        final PasswordChangeModule module = new PasswordChangeModule(oldPasswordView);
        View moduleView = module.generateUI(this);
        moduleViewMap.put(module, moduleView);
        inputContainer.addView(moduleView);

        // create a dialog
        final AlertDialog dialog = new AlertDialog.Builder(SvmpActivity.this).setCancelable(false)
                .setTitle(R.string.authPrompt_title_passwordChange).setView(inputContainer)
                .setPositiveButton(R.string.authPrompt_button_positive_text, null).setNegativeButton(
                        R.string.authPrompt_button_negative_text, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                busy = false;
                            }
                        })
                .create();

        // override positive button
        dialog.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface d) {
                Button positive = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
                if (positive != null) {
                    positive.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View view) {
                            // before continuing, validate the new password inputs
                            int resId = module.areInputsValid();
                            if (resId == 0) {
                                dialog.dismiss(); // inputs are valid, dismiss the dialog
                                startAppRTCWithAuth(connectionInfo, moduleViewMap);
                            } else {
                                // tell the user that the new password is not valid
                                toastShort(resId);
                            }
                        }
                    });
                }
            }
        });

        // show the dialog
        dialog.show();
        // request keyboard
        dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    }
}

From source file:org.ounl.lifelonglearninghub.fcube.navigate.SwipeFragmentActivity.java

/**
 * On click one audio radiobutton, deselect the rest of the radiobuttons
 * //  w w w  . ja  va  2s .com
 * @param v
 */
public void onSelectAudioRadioButton(View v) {

    LinearLayout llRadioButton = (LinearLayout) v.getParent();
    LinearLayout llRoot = (LinearLayout) llRadioButton.getParent();

    RadioButton rbB = (RadioButton) llRoot.findViewById(R.id.rbBeep);
    RadioButton rbM = (RadioButton) llRoot.findViewById(R.id.rbMelody1);

    String sTag = v.getTag().toString();
    if (getString(R.string.rb_beep).compareTo(sTag) == 0) {

        rbM.setChecked(false);

    } else if (getString(R.string.rb_melody).compareTo(sTag) == 0) {

        rbB.setChecked(false);

    }

}