Example usage for android.widget RelativeLayout findViewById

List of usage examples for android.widget RelativeLayout findViewById

Introduction

In this page you can find the example usage for android.widget RelativeLayout 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.appnexus.opensdkapp.DebugFragment.java

private void createDebugAuctionDialog() {
    // hacked to be fullscreen with minHeight. see xml
    RelativeLayout frame = (RelativeLayout) getActivity().getLayoutInflater().inflate(R.layout.dialog_debug,
            null, false);//from w  w  w  .j a  va  2 s .co  m
    View placeholderView = frame.findViewById(R.id.debug_auction_view);

    pullToRefreshView = new PullToRefreshWebView(getActivity().getApplicationContext());
    WebView webView = pullToRefreshView.getRefreshableView();
    webViewClient = new DebugAuctionWebViewClient(webView);
    webView.setWebViewClient(webViewClient);

    pullToRefreshView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<WebView>() {
        @Override
        public void onRefresh(PullToRefreshBase<WebView> refreshView) {
            webViewClient.runAuction();
        }
    });

    pullToRefreshView.setLayoutParams(placeholderView.getLayoutParams());
    // make sure the close button is on top of the webView
    frame.addView(pullToRefreshView, 1);

    debugDialog = new AlertDialog.Builder(getActivity()).setView(frame).create();

    ImageButton close = (ImageButton) frame.findViewById(R.id.debug_btn_close);
    close.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if (debugDialog != null)
                debugDialog.dismiss();
        }
    });

    Button email = (Button) frame.findViewById(R.id.debug_btn_email);
    email.setOnClickListener(emailDebugAuctionOnClickListener);
}

From source file:nu.yona.app.ui.settings.SettingsFragment.java

private ListView setUpListItemOnClickListener(ListView settingsListView) {
    settingsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override/*from w ww  . java 2 s .c om*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            RelativeLayout listRelativeLayout = view.findViewById(R.id.list_relative_layout);
            YonaFontTextView yonaFontTextView = listRelativeLayout.findViewById(R.id.list_title);
            String listItemTitle = yonaFontTextView.getText().toString();
            if (listItemTitle.equals(getString(R.string.changepin))) {
                showChangePin();
            } else if (listItemTitle.equals(getString(R.string.privacy))) {
                showPrivacy();
            } else if (listItemTitle.equals(getString(R.string.adddevice))) {
                addDevice(AppUtils.getRandomString(AppConstant.ADD_DEVICE_PASSWORD_CHAR_LIMIT));
            } else if (listItemTitle.equals(getString(R.string.deleteuser))) {
                unsubscribeUser();
            } else if (listItemTitle.equals(getString(R.string.contact_us))) {
                openEmail();
            } else if (listItemTitle.equals(getString(R.string.showopenvpnlog))) {
                toggleVPNLogWindowDisplay();
            }
        }
    });
    return settingsListView;
}

From source file:org.montanafoodhub.app.producer.ProducerDetailFragment.java

private void loadCertifications(View view) {

    LinearLayout linearLayout = (LinearLayout) view.findViewById(R.id.certificationLayout);
    linearLayout.removeAllViews();// ww  w. ja  v a2s .com

    ImageCache imageCache = ((HubApplication) getActivity().getApplication()).getImageCache();

    for (Certification cert : _producer.getCertifications()) {
        RelativeLayout relativeLayout = (RelativeLayout) LayoutInflater.from(getActivity())
                .inflate(R.layout.certification, null);
        relativeLayout.setOnClickListener(this);
        relativeLayout.setTag(cert);

        ImageView imageView = (ImageView) relativeLayout.findViewById(R.id.certificationImageview);
        imageCache.loadImage(imageView, cert.getIconUrl(), R.drawable.default_certification);

        TextView textView = (TextView) relativeLayout.findViewById(R.id.certificationText);
        textView.setText(cert.getDisplayName());

        linearLayout.addView(relativeLayout);
    }
}

From source file:com.nice295.scratchgames.fragment.BestFragment.java

@Nullable
@Override//from w ww  .ja  va2  s .  c om
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RelativeLayout ll = (RelativeLayout) inflater.inflate(R.layout.fragment_best, container, false);

    //mBestItemArray = new ArrayList<BestItem>();
    mBestItemArray = Paper.book().read("best", new ArrayList<BestItem>());

    mLvMyItems = (ListView) ll.findViewById(R.id.lvBest);
    mAdapter = new ListViewAdapter(getActivity(), R.layout.layout_item_best, mBestItemArray);
    mLvMyItems.setAdapter(mAdapter);

    // Obtain the FirebaseAnalytics instance.
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(getActivity());
    mDatabase = FirebaseDatabase.getInstance().getReference();

    Query myTopPostsQuery = mDatabase.child("best").orderByChild("star");
    myTopPostsQuery.addValueEventListener(
            //mDatabase.child("my-items").addValueEventListener(
            new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    mBestItemArray.clear();

                    if (dataSnapshot.getChildrenCount() != 0) {
                        for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
                            BestItem item = postSnapshot.getValue(BestItem.class);
                            mBestItemArray.add(item);
                        }
                        mAdapter.notifyDataSetChanged();

                        Paper.book().write("best", mBestItemArray);
                    }
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {
                    Log.w(TAG, "my-items:onCancelled", databaseError.toException());
                }
            });

    mLvMyItems.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Intent intent = new Intent(getActivity(), ShowWebView.class);
            BestItem item = mAdapter.getItem().get(i);

            intent.putExtra("id", item.getId());
            intent.putExtra("user", item.getUser());
            intent.putExtra("name", item.getName());

            startActivity(intent);
        }
    });

    return ll;
}

From source file:com.stephenmcgruer.simpleupnp.fragments.ServerBrowserFragment.java

@Nullable
@Override/*  w w w .j ava2  s .  com*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    RelativeLayout relativeLayoutView = (RelativeLayout) inflater.inflate(R.layout.fragment_server_browser,
            container, false);

    ListView serverListView = (ListView) relativeLayoutView.findViewById(R.id.server_browser_list);
    mServerListAdapter = new ArrayAdapter<>(serverListView.getContext(), R.layout.fragment_server_browser_item);
    serverListView.setAdapter(mServerListAdapter);
    serverListView.setOnItemClickListener(this);

    mBookmarkTextView = (TextView) relativeLayoutView.findViewById(R.id.bookmarks_text);

    ListView bookmarkListView = (ListView) relativeLayoutView.findViewById(R.id.bookmarks_list);
    mBookmarkListAdapter = new ArrayAdapter<>(bookmarkListView.getContext(),
            R.layout.fragment_server_browser_item);
    bookmarkListView.setAdapter(mBookmarkListAdapter);
    bookmarkListView.setOnItemClickListener(this);

    return relativeLayoutView;
}

From source file:com.nice295.fridgeplease.fragment.ItemsFragment.java

@Nullable
@Override//from  ww  w  .j  a  v a2 s.  co  m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RelativeLayout ll = (RelativeLayout) inflater.inflate(R.layout.fragment_items, container, false);

    mMyItemArray = new ArrayList<MyItem>();
    mLvMyItems = (ListView) ll.findViewById(R.id.lvMembers);
    mAdapter = new ListViewAdapter(getActivity(), R.layout.layout_item_list_item, mMyItemArray);
    mLvMyItems.setAdapter(mAdapter);

    // Obtain the FirebaseAnalytics instance.
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(getActivity());
    mDatabase = FirebaseDatabase.getInstance().getReference();

    //Paper.init(getActivity());

    mItems = Paper.book().read("items", new HashMap<String, String>());

    mDatabase.child("items").addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            Log.d(TAG, "Total items count: " + dataSnapshot.getChildrenCount());

            if (dataSnapshot.getChildrenCount() == 0) {
                initItems();
            } else {
                mItems.clear();
                for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
                    Item item = postSnapshot.getValue(Item.class);
                    Log.d(TAG, "Name: " + item.getName());
                    Log.d(TAG, "URL: " + item.getImageUrl());
                    mItems.put(item.getName().toLowerCase(), item.getImageUrl());
                }

                Paper.book().write("items", mItems);
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            Log.w(TAG, "items:onCancelled", databaseError.toException());
        }
    }

    );

    Query myTopPostsQuery = mDatabase.child("my-items").orderByChild("time");
    myTopPostsQuery.addValueEventListener(
            //mDatabase.child("my-items").addValueEventListener(
            new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    mMyItemArray.clear();

                    if (dataSnapshot.getChildrenCount() == 0) {
                        //initMyItems();
                    } else {
                        for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
                            MyItem item = postSnapshot.getValue(MyItem.class);
                            Log.d(TAG, "Name: " + item.getName());
                            Log.d(TAG, "Time: " + item.getTime());
                            Log.d(TAG, "URL: " + item.getImageUrl());

                            mMyItemArray.add(item);
                        }

                        mAdapter.notifyDataSetChanged();
                    }
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {
                    Log.w(TAG, "my-items:onCancelled", databaseError.toException());
                }
            });

    return ll;
}

From source file:com.cloudkick.monitoring.Check.java

@Override
public View getItemView(Context context, View convertView, ViewGroup parent) {
    RelativeLayout checkView;

    String inflater = Context.LAYOUT_INFLATER_SERVICE;
    LayoutInflater li = (LayoutInflater) context.getSystemService(inflater);

    if (convertView == null) {
        checkView = new RelativeLayout(context);
        li.inflate(R.layout.node_detail, checkView, true);
    }//from   w  w w.j  av a  2 s  .c o  m

    else {
        checkView = (RelativeLayout) convertView;
    }

    ((TextView) checkView.findViewById(R.id.detail_label)).setText(summary);
    ((TextView) checkView.findViewById(R.id.detail_symbol)).setTextColor(latestState.stateColor);
    ((TextView) checkView.findViewById(R.id.detail_symbol)).setText(latestState.stateSymbol);
    ((TextView) checkView.findViewById(R.id.detail_value)).setText(latestState.status);

    return checkView;
}

From source file:cn.wander.Utils.views.pageindicator.TabPageIndicator.java

private void addTab(int index, CharSequence text, int iconResId) {
    RelativeLayout tablayout = (RelativeLayout) View.inflate(getContext(), R.layout.tab_item_layout, null);

    final TextView tabView = (TextView) tablayout.findViewById(R.id.tab_item_title);
    tabView.setTag(index);/*from www.j  a  v a2 s .c om*/
    tabView.setFocusable(true);
    tabView.setOnClickListener(mTabClickListener);
    tabView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 19);
    tabView.setText(text);
    tabView.setTextColor(getResources().getColor(R.color.kw_common_cl_white));
    if (iconResId != 0) {
        //             tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
        ImageView iconView = (ImageView) tablayout.findViewById(R.id.tab_item_icon);
        iconView.setImageResource(iconResId);
        iconView.setVisibility(View.VISIBLE);
    }

    mTabLayout.addView(tablayout, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
}

From source file:com.nadmm.airports.wx.PirepFragment.java

protected void showPirepEntry(LinearLayout layout, PirepEntry entry) {
    RelativeLayout item = (RelativeLayout) inflate(R.layout.pirep_detail_item);

    TextView tv = (TextView) item.findViewById(R.id.pirep_title);
    if (entry.flags.contains(Flags.BadLocation)) {
        String dir = GeoUtils.getCardinalDirection(entry.bearing);
        tv.setText(String.format("%.0f NM %s approx.", entry.distanceNM, dir));
    } else if (entry.distanceNM > 0) {
        String dir = GeoUtils.getCardinalDirection(entry.bearing);
        tv.setText(String.format("%.0f NM %s", entry.distanceNM, dir));
    } else {/*from   w w w  .ja v a  2  s. com*/
        tv.setText(String.format("On Site"));
    }

    tv = (TextView) item.findViewById(R.id.pirep_title_extra);
    tv.setText(TimeUtils.formatElapsedTime(entry.observationTime));

    tv = (TextView) item.findViewById(R.id.wx_raw_pirep);
    tv.setText(entry.rawText);

    LinearLayout details = (LinearLayout) item.findViewById(R.id.pirep_details);

    addRow(details, "Type", entry.reportType);
    addRow(details, "Aircraft", entry.aircraftRef);

    String time = TimeUtils.formatDateTime(getActivity(), entry.observationTime);
    addRow(details, "Time", time);

    if (entry.altitudeFeetMSL < Integer.MAX_VALUE) {
        if (entry.flags.contains(Flags.NoFlightLevel)) {
            addRow(details, "Altitude", FormatUtils.formatFeetMsl(entry.altitudeFeetMSL), "(Approximate)");
        } else {
            addRow(details, "Altitude", FormatUtils.formatFeetMsl(entry.altitudeFeetMSL));
        }
    }

    if (entry.visibilitySM < Integer.MAX_VALUE) {
        addRow(details, "Visibility", FormatUtils.formatStatuteMiles(entry.visibilitySM));
    }

    if (entry.tempCelsius < Integer.MAX_VALUE) {
        addRow(details, "Temperature", FormatUtils.formatTemperature(entry.tempCelsius));
    }

    if (entry.windSpeedKnots < Integer.MAX_VALUE) {
        addRow(details, "Winds", String.format("%s (true) at %d knots",
                FormatUtils.formatDegrees(entry.windDirDegrees), entry.windSpeedKnots));
    }

    if (!entry.wxList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (WxSymbol wx : entry.wxList) {
            if (sb.length() > 0) {
                sb.append(", ");
            }
            sb.append(wx.toString());
        }
        addRow(details, "Weather", sb.toString());
    }

    for (SkyCondition sky : entry.skyConditions) {
        addSkyConditionRow(details, sky);
    }

    for (TurbulenceCondition turbulence : entry.turbulenceConditions) {
        addTurbulenceRow(details, turbulence);
    }

    for (IcingCondition icing : entry.icingConditions) {
        addIcingRow(details, icing);
    }

    layout.addView(item, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
}

From source file:de.tudarmstadt.informatik.secuso.phishedu2.PhishBaseActivity.java

protected void updateScore(View view) {
    if (view == null) {
        return;/*from  www.  ja v  a2s .c o m*/
    }
    RelativeLayout scores = (RelativeLayout) view.findViewById(R.id.score_relative);
    if (scores != null) {
        TextView urlsText = (TextView) scores.findViewById(R.id.urls);
        TextView urlsGoalText = (TextView) scores.findViewById(R.id.urls_goal);
        ImageView lifeOne = (ImageView) scores.findViewById(R.id.life_1);
        ImageView lifeTwo = (ImageView) scores.findViewById(R.id.life_2);
        ImageView lifeThree = (ImageView) scores.findViewById(R.id.life_3);
        TextView LevelScoreText = (TextView) scores.findViewById(R.id.level_score);

        urlsText.setText(Integer.toString(BackendControllerImpl.getInstance().getCorrectlyFoundURLs()));
        urlsGoalText.setText(
                Integer.toString(BackendControllerImpl.getInstance().getLevelInfo().levelCorrectURLs()));
        LevelScoreText.setText(Integer.toString(BackendControllerImpl.getInstance().getLevelPoints()));

        int remaininLives = BackendControllerImpl.getInstance().getLifes();

        //now hide hearts if required
        switch (remaininLives) {
        case 0:
            //hide all hearts
            lifeOne.setVisibility(View.INVISIBLE);
            lifeTwo.setVisibility(View.INVISIBLE);
            lifeThree.setVisibility(View.INVISIBLE);
            break;
        case 1:
            //hide heart 1 and 2
            lifeOne.setVisibility(View.INVISIBLE);
            lifeTwo.setVisibility(View.INVISIBLE);
            break;
        case 2:
            //hide only heart 1
            lifeOne.setVisibility(View.INVISIBLE);
        default:
            break;
        }
    }
}