List of usage examples for android.view View findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:com.polatic.pantaudki.home.HomeFragment.java
/** * View initialization// ww w.j ava 2s.c o m * * @param rootView */ private void initView(View rootView) { mContext = getActivity().getApplicationContext(); progressBar = (ProgressBar) rootView.findViewById(R.id.home_progress_bar); messageSystemTextView = (TextView) rootView.findViewById(R.id.home_message_system); ViewPager mViewPager = (ViewPager) rootView.findViewById(R.id.home_view_pager); mViewPager.setAdapter(new SectionsPagerAdapter(getChildFragmentManager())); }
From source file:de.kirchnerei.bicycle.battery.BatteryDetailFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mDate = (TextView) view.findViewById(R.id.battery_date); mDistance = (TextView) view.findViewById(R.id.battery_distance); mAverageSpeed = (TextView) view.findViewById(R.id.battery_average_speed); mMileage = (TextView) view.findViewById(R.id.battery_mileage); mLeftover = (TextView) view.findViewById(R.id.battery_leftover); }
From source file:org.npr.android.news.StationListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { View line = super.getView(position, convertView, parent); Station station = getItem(position); TextView name = (TextView) line.findViewById(R.id.StationItemNameText); name.setText(Html.fromHtml(station.getName())); TextView location = (TextView) line.findViewById(R.id.StationItemLocationText); location.setText(Html.fromHtml(station.getMarketCity())); TextView frequency = (TextView) line.findViewById(R.id.StationItemFrequencyText); if (station.getFrequency() != null && station.getBand() != null) { frequency.setText(Html.fromHtml(String.format("%s %s", station.getFrequency(), station.getBand()))); } else {/*from ww w .j a v a2 s. c om*/ frequency.setText(""); } if (favoriteStationsRepository != null) { TextView preset = (TextView) line.findViewById(R.id.StationPresetView); FavoriteStationEntry favoriteStationEntry = favoriteStationsRepository .getFavoriteStationForStationId(station.getId()); if (favoriteStationEntry != null && favoriteStationEntry.preset != null) { preset.setText(favoriteStationEntry.preset); preset.setVisibility(View.VISIBLE); } else { preset.setVisibility(View.INVISIBLE); } } return line; }
From source file:de.vanita5.twittnuker.popup.AccountSelectorPopupWindow.java
public AccountSelectorPopupWindow(Context context, View anchor) { mContext = context;/*from www. ja v a 2s . c o m*/ mAnchor = anchor; final int themeAttr; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { themeAttr = android.R.attr.actionOverflowMenuStyle; } else { themeAttr = android.R.attr.popupMenuStyle; } mAdapter = new AccountsGridAdapter(context); final Resources resources = context.getResources(); final LayoutInflater inflater = LayoutInflater.from(context); final int themeColor = ThemeUtils.getUserAccentColor(context); if (!(context instanceof Factory)) { inflater.setFactory2(new ThemedViewFactory(themeColor)); } final View contentView = inflater.inflate(R.layout.popup_account_selector, null); mGridView = (GridView) contentView.findViewById(R.id.grid_view); mGridView.setAdapter(mAdapter); mGridView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE); mGridView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (mAccountSelectionListener == null) return; mAccountSelectionListener.onSelectionChanged(getSelectedAccountIds()); } }); mPopup = new PopupWindow(context, null, themeAttr); mPopup.setFocusable(true); mPopup.setWidth(Utils.getActionBarHeight(context) * 2); mPopup.setWindowLayoutMode(0, ViewGroup.LayoutParams.WRAP_CONTENT); mPopup.setContentView(contentView); }
From source file:gov.in.bloomington.georeporter.fragments.PersonalInfoFragment.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { super.onListItemClick(l, v, position, id); final String fieldname = PersonalInfoAdapter.FIELDS[position]; final TextView label = (TextView) v.findViewById(android.R.id.text1); final TextView input = (TextView) v.findViewById(android.R.id.text2); final EditText newValue = new EditText(getActivity()); newValue.setText(input.getText());/*from w w w .ja v a2 s. co m*/ int type = InputType.TYPE_TEXT_FLAG_CAP_WORDS; if (fieldname == "email") { type = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; } if (fieldname == "phone") { type = InputType.TYPE_CLASS_PHONE; } newValue.setInputType(type); new AlertDialog.Builder(getActivity()).setTitle(label.getText()).setView(newValue) .setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { mPersonalInfo.put(fieldname, newValue.getText()); } catch (JSONException e) { // Just ignore any errors } } }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Do Nothing } }).show(); }
From source file:in.codehex.facilis.PlaceBidFragment.java
/** * Initialize the objects./*from w w w . ja v a 2 s .c o m*/ * * @param view the root view of the layout. */ private void initObjects(View view) { mRecyclerView = (RecyclerView) view.findViewById(R.id.place_bid_list); mViewOrderItemList = new ArrayList<>(); mLayoutManager = new LinearLayoutManager(getContext()); mAdapter = new ViewOrderItemsAdapter(getContext(), mViewOrderItemList); userPreferences = getActivity().getSharedPreferences(Config.PREF_USER, Context.MODE_PRIVATE); }
From source file:com.example.android.donebar.DoneButtonActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // BEGIN_INCLUDE (inflate_set_custom_view) // Inflate a "Done" custom action bar view to serve as the "Up" affordance. final LayoutInflater inflater = (LayoutInflater) getActionBar().getThemedContext() .getSystemService(LAYOUT_INFLATER_SERVICE); final View customActionBarView = inflater.inflate(R.layout.actionbar_custom_view_done, null); customActionBarView.findViewById(R.id.actionbar_done).setOnClickListener(new View.OnClickListener() { @Override//from w ww .ja va 2 s . co m public void onClick(View v) { // "Done" finish(); } }); // Show the custom action bar view and hide the normal Home icon and title. final ActionBar actionBar = getActionBar(); actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); actionBar.setCustomView(customActionBarView); // END_INCLUDE (inflate_set_custom_view) AsyncHttpClient client = new AsyncHttpClient(); client.get("http://192.168.0.101:8080/AndroidRESTful2/webresources/com.erikchenmelbourne.entities.caller", new JsonHttpResponseHandler() { @Override public void onSuccess(int statusCode, org.apache.http.Header[] headers, org.json.JSONArray response) { if (response != null) { String string = response.toString(); try { JSONArray jsonarray = new JSONArray(string); Caller.jsonarraylist.clear(); populateArrayList(jsonarray, Caller.jsonarraylist); /*for (int i = 0; i < Caller.jsonarraylist.size(); i++) { Toast.makeText(getApplicationContext(), Caller.jsonarraylist.get(i).toString(), Toast.LENGTH_LONG).show(); }*/ } catch (JSONException e) { e.printStackTrace(); } } else { Toast.makeText(getApplicationContext(), "Status Code: " + statusCode + " Data has been posted.", Toast.LENGTH_LONG) .show(); } } @Override public void onFailure(int statusCode, org.apache.http.Header[] headers, java.lang.Throwable throwable, org.json.JSONArray errorResponse) { if (statusCode == 404) { Toast.makeText(getApplicationContext(), "Requested resource not found.", Toast.LENGTH_LONG).show(); } else if (statusCode == 500) { Toast.makeText(getApplicationContext(), "Something went wrong at server end.", Toast.LENGTH_LONG).show(); } else { Toast.makeText(getApplicationContext(), "Unexpected Error occurred. [Most common Error: Device might not be connected to Internet or remote server is not up and running]", Toast.LENGTH_LONG).show(); } } }); setContentView(R.layout.activity_done_button); }
From source file:org.flakor.androidtool.net.net.HistoryTask.java
@Override protected void onPostExecute(Integer i) { if (i < 0) { if (dialog != null) dialog.dismiss();/*from ww w .jav a 2s . c o m*/ Toast.makeText(context, "?", Toast.LENGTH_SHORT).show(); } else if (i >= 0) { View view = LayoutInflater.from(context).inflate(R.layout.dialog_history, null); ListView list = (ListView) view.findViewById(R.id.history_list); if (i == 0) { TextView noHistory = (TextView) view.findViewById(R.id.no_history); noHistory.setVisibility(View.VISIBLE); list.setVisibility(View.GONE); } else { RemoteHistoryAdapter adapter = new RemoteHistoryAdapter(context); list.setAdapter(adapter); } TextView title = (TextView) view.findViewById(R.id.dialog_title); title.setText("??"); Button okBtn = (Button) view.findViewById(R.id.ok_btn); okBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.setContentView(view); Toast.makeText(context, "??", Toast.LENGTH_SHORT).show(); } else { if (dialog != null) dialog.dismiss(); Toast.makeText(context, "???", Toast.LENGTH_SHORT).show(); } }
From source file:com.lgallardo.qbittorrentclient.TorrentDetailsFragment.java
/** * */*from w w w.j a v a 2 s.co m*/ * Method for Setting the Height of the ListView dynamically. Hack to fix * the issue of not showing all the items of the ListView when placed inside * a ScrollView * ** */ public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) return; int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.UNSPECIFIED); int totalHeight = 0; View view = null; for (int i = 0; i < listAdapter.getCount(); i++) { long numOfLines = 1; view = listAdapter.getView(i, view, listView); if (i == 0) { view.setLayoutParams(new LayoutParams(desiredWidth, LayoutParams.WRAP_CONTENT)); } view.measure(desiredWidth, MeasureSpec.UNSPECIFIED); TextView file = (TextView) view.findViewById(R.id.file); TextView percentage = (TextView) view.findViewById(R.id.percentage); ProgressBar progressBar1 = (ProgressBar) view.findViewById(R.id.progressBar1); if (view.getMeasuredWidth() > desiredWidth) { double viewWidthLong = Double.valueOf(view.getMeasuredWidth()); double desiredWidthLong = Double.valueOf(desiredWidth); numOfLines = Math.round(viewWidthLong / desiredWidthLong) + 1; totalHeight += (file.getMeasuredHeight() * numOfLines) + percentage.getMeasuredHeight() + progressBar1.getMeasuredHeight(); } else { totalHeight += view.getMeasuredHeight(); } } LayoutParams params = listView.getLayoutParams(); params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutParams(params); listView.requestLayout(); }
From source file:com.app.jdy.widget.CustomSaveMoneyDialog.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.savemoney_dialog); listView = (ListView) findViewById(R.id.savemoney_listView); promoCodeTextView = (TextView) findViewById(R.id.PromoCode); listView.setOnItemClickListener(new OnItemClickListener() { @Override/*from ww w. j ava2 s. c om*/ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { addressTextView = (TextView) arg1.findViewById(R.id.address); Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + addressTextView.getText())); context.startActivity(intent); } }); new Thread(ManagerRunnable).start(); mHandler = new Handler() { @Override public void handleMessage(Message msg) {// ui? switch (msg.what) { case 2: customManagerAdapter = new CustomManagerAdapter(context, listViewProductManagerList); listView.setAdapter(customManagerAdapter); break; case 3: promoCodeTextView.setText(coupon); break; default: break; } } }; }