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.rainmakerlabs.bleepsample.BleepService.java

public void imgShow(Bitmap bitmap, String strImgMsg) {
    MainActivity.adlib.put(strImgMsg, bitmap);
    Log.d("Portal", "Added an image. Size is now " + MainActivity.adlib.size());
    Log.i("Portal", "Image added for key " + strImgMsg);

    if (MainActivity.myGallery == null)
        return;//  ww  w  . ja v a2  s .c  o m

    if (MainActivity.gal_size < MainActivity.adlib.size()) { //new image has been added and the layout is initialized
        LinearLayout superLL = (LinearLayout) MainActivity.myGallery.getParent().getParent();

        if (MainActivity.gal_size < 1) {
            ImageView imgSplash = (ImageView) superLL.findViewById(R.id.imgSplash);
            imgSplash.setVisibility(View.INVISIBLE);
        }

        LinearLayout layout = new LinearLayout(getApplicationContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        layout.setGravity(Gravity.CENTER);

        ImageView imageview = new ImageView(getApplicationContext());
        imageview.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 1000));
        imageview.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageview.setImageBitmap(bitmap);

        //Add a button to go with it
        Button btnBuy = new Button(getApplicationContext());
        LinearLayout.LayoutParams btnParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT);
        btnParams.setMargins(-10, -10, -10, -10);
        btnBuy.setLayoutParams(btnParams);
        btnBuy.setText("Buy Now (" + strImgMsg + ")");
        btnBuy.setBackgroundColor(MainActivity.getDominantColor(bitmap));
        btnBuy.setTextColor(Color.WHITE);

        btnBuy.setOnClickListener(new Button.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent newActivity = new Intent(getApplicationContext(), WebActivity.class);
                newActivity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                newActivity.putExtra("URL", "https://portal-battlehack.herokuapp.com/");
                startActivity(newActivity);
            }
        });

        layout.addView(imageview);
        layout.addView(btnBuy);
        MainActivity.myGallery.addView(layout);
        MainActivity.gal_size++;
    }

}

From source file:com.gigathinking.simpleapplock.AppListFragment.java

@Override
public void onStart() {
    super.onStart();

    if (!noAds) {
        final AdView adView = (AdView) getActivity().findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().addTestDevice("YOUR DEVICE 1")
                .addTestDevice("YOUR DEVICE 2").build();
        adView.loadAd(adRequest);//from   w  ww .java 2 s  .co m
        adView.setAdListener(new AdListener() {
            @Override
            public void onAdLoaded() {
                LinearLayout ll = (LinearLayout) getActivity().findViewById(R.id.id_ll_app_list);
                ll.findViewById(R.id.adView).setVisibility(View.VISIBLE);
            }
        });
    } else {
        (getActivity().findViewById(R.id.adView)).setVisibility(View.GONE);
    }

    interstitial = new InterstitialAd(getActivity());
    interstitial.setAdUnitId("YOUR AD UNIT ID");
    interstitial.setAdListener(new AdListener() {
        @Override
        public void onAdClosed() {
            super.onAdClosed();
            mPrefs.edit().putInt("ad_count", (mPrefs.getInt("ad_count", 0) + 1)).commit();
        }
    });

    // Create ad request.
    AdRequest adRequestInterestial = new AdRequest.Builder().addTestDevice("YOUR DEVICE 1")
            .addTestDevice("YOUR DEVICE 2").build();

    // Begin loading your interstitial.
    if (!noAds) {
        interstitial.loadAd(adRequestInterestial);
    }

    if (!mList.isEmpty()) {
        showInitialStart(false);
    } else {
        showInitialStart(true);
    }
    AbsListView listView = (AbsListView) getActivity().findViewById(R.id.lv_app_list);
    listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(this);
    mAdapter = new AppListAdapter(getActivity(), R.layout.layout_applist_item, mList);
    listView.setAdapter(mAdapter);
    listView.setOnItemClickListener(this);
    receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (isAdded()) {
                startActivityForResult(new Intent(context, AppPicker.class), 22);
            }
        }
    };
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver,
            new IntentFilter(AppLockApplication.LAUNCH_PICKER));

    //Limit 5 interstitial ads per day.
    int today = Integer.parseInt(DateFormat.format("d", Calendar.getInstance()).toString());
    if (mPrefs.getInt("today", 0) != today) {
        mPrefs.edit().putInt("ad_count", 0).commit();
        mPrefs.edit().putInt("today", today).commit();
    }
}

From source file:com.jihao.imtest.viewpager.PagerSlidingTabStrip.java

public void updateTab(int index, int unread) {
    LinearLayout tabView = (LinearLayout) tabsContainer.getChildAt(index);
    ImageView indicatorView = (ImageView) tabView.findViewById(R.id.tab_new_indicator);
    TextView unreadLbl = (TextView) tabView.findViewById(R.id.tab_new_msg_label);

    if (unreadLbl == null || indicatorView == null) {
        unreadLbl.setVisibility(View.GONE);
        indicatorView.setVisibility(View.GONE);
        return;/* w  ww .  ja  v a2  s .  c o m*/
    }
    unreadLbl.setVisibility(unread > 0 ? View.VISIBLE : View.GONE);
    //        indicatorView.setVisibility(indicator ? View.VISIBLE : View.GONE);
    if (unread > 0) {
        unreadLbl.setText(String.valueOf(unread));
    }
}

From source file:com.money.manager.ex.home.DashboardFragment.java

private View showTableLayoutTopPayees(Cursor cursor) {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dashboard_summary_layout, null);
    CurrencyService currencyService = new CurrencyService(getActivity().getApplicationContext());

    // Textview Title
    TextView title = (TextView) layout.findViewById(R.id.textViewTitle);
    title.setText(R.string.top_payees_last_30_days);
    // Table/*from ww w .  j  a v a2s  .com*/
    TableLayout tableLayout = (TableLayout) layout.findViewById(R.id.tableLayoutSummary);
    // Create Title
    tableLayout.addView(createTableRow(
            new String[] { "<small><b>" + getString(R.string.payee) + "</b></small>",
                    "<small><b>" + getString(R.string.quantity) + "</b></small>",
                    "<small><b>" + getString(R.string.summary) + "</b></small>" },
            new Float[] { 1f, null, null }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT },
            new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null }));
    // add rows
    while (cursor.moveToNext()) {
        // load values
        String payee = cursor.getString(cursor.getColumnIndex(ViewMobileData.PAYEE));
        double total = cursor.getDouble(cursor.getColumnIndex("TOTAL"));
        int num = cursor.getInt(cursor.getColumnIndex("NUM"));
        // Add Row
        tableLayout.addView(createTableRow(
                new String[] { "<small>" + payee + "</small>",
                        "<small><i>" + Integer.toString(num) + "</i></small>",
                        "<small>" + currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(),
                                MoneyFactory.fromDouble(total)) + "</small>" },
                new Float[] { 1f, null, null }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT },
                new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null }));
    }

    // return Layout
    return layout;
}

From source file:com.money.manager.ex.home.DashboardFragment.java

private View showTableLayoutTopWithdrawals(Cursor cursor) {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dashboard_summary_layout, null);
    CurrencyService currencyService = new CurrencyService(getActivity().getApplicationContext());

    // Textview Title
    TextView title = (TextView) layout.findViewById(R.id.textViewTitle);
    title.setText(R.string.top_withdrawals_last_30_days);
    // Table//w  w w .ja v a  2  s .co  m
    TableLayout tableLayout = (TableLayout) layout.findViewById(R.id.tableLayoutSummary);
    // Create Title
    tableLayout.addView(createTableRow(
            new String[] { "<small><b>" + getString(R.string.category) + "</b></small>",
                    "<small><b>" + getString(R.string.quantity) + "</b></small>",
                    "<small><b>" + getString(R.string.summary) + "</b></small>" },
            new Float[] { 1f, null, null }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT },
            new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null }));
    // add rows
    while (cursor.moveToNext()) {
        // load values
        String category = "<b>" + cursor.getString(cursor.getColumnIndex(ViewMobileData.Category)) + "</b>";
        if (!TextUtils.isEmpty(cursor.getString(cursor.getColumnIndex(ViewMobileData.Subcategory)))) {
            category += " : " + cursor.getString(cursor.getColumnIndex(ViewMobileData.Subcategory));
        }
        double total = cursor.getDouble(cursor.getColumnIndex("TOTAL"));
        int num = cursor.getInt(cursor.getColumnIndex("NUM"));
        // Add Row
        tableLayout.addView(createTableRow(
                new String[] { "<small>" + category + "</small>",
                        "<small><i>" + Integer.toString(num) + "</i></small>",
                        "<small>" + currencyService.getCurrencyFormatted(currencyService.getBaseCurrencyId(),
                                MoneyFactory.fromDouble(total)) + "</small>" },
                new Float[] { 1f, null, null }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT },
                new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null }));
    }
    // return Layout
    return layout;
}

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

/**
 * Marks a question as "left blank" when its corresponding question notification is deleted.
 *///from   w  ww .  ja v a2 s.c o  m
private void markQuestionLeftBlank(int index) {
    LinearLayout questionStatusElement = (LinearLayout) questionsContainer.getChildAt(index);
    if (questionStatusElement != null) {
        TextView questionText = (TextView) questionStatusElement.findViewById(R.id.question);
        TextView questionStatus = (TextView) questionStatusElement.findViewById(R.id.status);
        if (questionStatus.getText().equals(getString(R.string.question_unanswered))) {
            questionText.setTextColor(Color.YELLOW);
            questionStatus.setText(R.string.question_left_blank);
            mNumSkipped++;
        }
    }
}

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

/**
 * Replaces sampler button in jukebox/*  ww w . j a  v a 2s . c  om*/
 * 
 * @param v
 */
public void onClickReplaceSamplerButton(View v) {

    // Rename button

    LinearLayout llButtons = (LinearLayout) v.getParent();
    LinearLayout llParent = (LinearLayout) llButtons.getParent();

    EditText etRen = (EditText) llParent.findViewById(R.id.editTextRename);
    String sNewName = etRen.getText().toString();
    Button but = (Button) v;
    but.setTextColor(Color.CYAN);
    but.setText(sNewName);

    //      Fragment f = mAppSectionsPagerAdapter.getItem(iActiveFragment);
    //
    //      
    //
    //      
    //      if(f.getClass().equals(VisualSectionFragment.class)){
    //         
    //         FCColor fcc = (FCColor)ifcc;
    //         Sampler samp = new Sampler(fcc, sNewName);
    //         FeedbackCubeConfig.getSingleInstance().addSampler((String)v.getTag(), samp, this);         
    //         
    //      }else if (f.getClass().equals(AudioSectionFragment.class)){
    //               
    //         FCBeep fcc = (FCBeep)ifcc;
    //         Sampler samp = new Sampler(fcc, sNewName);
    //         FeedbackCubeConfig.getSingleInstance().addSampler((String)v.getTag(), samp, this);         
    //         
    //      }else if (f.getClass().equals(EffectsSectionFragment.class)){
    //         
    //         
    //         if(ifcc.getClass().equals(FCRainbow.class)){
    //            FCRainbow fcc = (FCRainbow)ifcc;
    //            Sampler samp = new Sampler(fcc, sNewName);
    //            FeedbackCubeConfig.getSingleInstance().addSampler((String)v.getTag(), samp, this);
    //         }else if (ifcc.getClass().equals(FCRainbowCircle.class)){
    //            FCRainbowCircle fcc = (FCRainbowCircle)ifcc;
    //            Sampler samp = new Sampler(fcc, sNewName);
    //            FeedbackCubeConfig.getSingleInstance().addSampler((String)v.getTag(), samp, this);
    //         }else if (ifcc.getClass().equals(FCFade.class){   
    //
    //         
    //            FCFade fcc = (FCFade)ifcc;
    //            Sampler samp = new Sampler(fcc, sNewName);
    //            FeedbackCubeConfig.getSingleInstance().addSampler((String)v.getTag(), samp, this);
    //         }
    //         
    //         
    //      }
    //      
    Sampler samp = new Sampler(ifcc, sNewName);
    FeedbackCubeConfig.getSingleInstance().addSampler((String) v.getTag(), samp, this);

}

From source file:com.tarot.sdfnash.tarot.common.ui.viewpager.PagerSlidingTabStrip.java

public void updateTab(int index, ReminderItem item) {
    LinearLayout tabView = (LinearLayout) tabsContainer.getChildAt(index);
    ImageView indicatorView = (ImageView) tabView.findViewById(R.id.tab_new_indicator);
    TextView unreadLbl = (TextView) tabView.findViewById(R.id.tab_new_msg_label);

    if (item == null || unreadLbl == null || indicatorView == null) {
        unreadLbl.setVisibility(View.GONE);
        indicatorView.setVisibility(View.GONE);
        return;// ww  w.  j  av  a2s .  c om
    }
    int unread = item.unread();
    boolean indicator = item.indicator();
    //   unreadLbl.setVisibility(unread > 0 ? View.VISIBLE : View.GONE);
    indicatorView.setVisibility(indicator ? View.VISIBLE : View.GONE);
    if (unread > 0) {
        unreadLbl.setText(String.valueOf(ReminderSettings.unreadMessageShowRule(unread)));
    }
}

From source file:com.aqtx.app.common.ui.viewpager.PagerSlidingTabStrip.java

public void updateTab(int index, ReminderItem item) {
    LinearLayout tabView = (LinearLayout) tabsContainer.getChildAt(index);
    ImageView indicatorView = (ImageView) tabView.findViewById(R.id.tab_new_indicator);
    TextView unreadLbl = (TextView) tabView.findViewById(R.id.tab_new_msg_label);

    if (item == null || unreadLbl == null || indicatorView == null) {
        unreadLbl.setVisibility(View.GONE);
        indicatorView.setVisibility(View.GONE);
        return;// w w w.ja v  a  2  s  .  c  om
    }
    int unread = item.unread();
    boolean indicator = item.indicator();
    unreadLbl.setVisibility(unread > 0 ? View.VISIBLE : View.GONE);
    indicatorView.setVisibility(indicator ? View.VISIBLE : View.GONE);
    if (unread > 0) {
        unreadLbl.setText(String.valueOf(ReminderSettings.unreadMessageShowRule(unread)));
    }
}

From source file:com.qbgg.cenglaicengqu.common.ui.viewpager.PagerSlidingTabStrip.java

public void updateTab(int index, com.qbgg.cenglaicengqu.main.reminder.ReminderItem item) {
    LinearLayout tabView = (LinearLayout) tabsContainer.getChildAt(index);
    ImageView indicatorView = (ImageView) tabView.findViewById(R.id.tab_new_indicator);
    TextView unreadLbl = (TextView) tabView.findViewById(R.id.tab_new_msg_label);

    if (item == null || unreadLbl == null || indicatorView == null) {
        unreadLbl.setVisibility(View.GONE);
        indicatorView.setVisibility(View.GONE);
        return;/*from ww w .  j  av a2  s  . c  o  m*/
    }
    int unread = item.unread();
    boolean indicator = item.indicator();
    unreadLbl.setVisibility(unread > 0 ? View.VISIBLE : View.GONE);
    indicatorView.setVisibility(indicator ? View.VISIBLE : View.GONE);
    if (unread > 0) {
        unreadLbl.setText(String.valueOf(ReminderSettings.unreadMessageShowRule(unread)));
    }
}