List of usage examples for android.widget TableRow findViewById
@Nullable public final <T extends View> T findViewById(@IdRes int id)
From source file:de.tobiasbielefeld.solitaire.ui.statistics.HighScoresFragment.java
/** * Loads the high score list/*from w w w . ja va 2 s. co m*/ */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_statistics_tab2, container, false); //if the app got killed while the statistics are open and then the user restarts the app, //my helper classes aren't initialized so they can't be used. In this case, simply //close the statistics try { loadData(); } catch (NullPointerException e) { getActivity().finish(); return view; } TableLayout tableLayout = (TableLayout) view.findViewById(R.id.statisticsTableHighScores); TextView textNoEntries = (TextView) view.findViewById(R.id.statisticsTextNoEntries); if (scores.getHighScore(0, 0) != 0) { textNoEntries.setVisibility(View.GONE); } for (int i = 0; i < Scores.MAX_SAVED_SCORES; i++) { //for each entry in highScores, add a new view with it if (scores.getHighScore(i, 0) == 0) { //if the score is zero, don't show it continue; } TableRow row = (TableRow) LayoutInflater.from(getContext()).inflate(R.layout.statistics_scores_row, null); TextView textView1 = (TextView) row.findViewById(R.id.row_cell_1); TextView textView2 = (TextView) row.findViewById(R.id.row_cell_2); TextView textView3 = (TextView) row.findViewById(R.id.row_cell_3); TextView textView4 = (TextView) row.findViewById(R.id.row_cell_4); textView1.setText(String.format(Locale.getDefault(), "%s %s", scores.getHighScore(i, 0), dollar)); long time = scores.getHighScore(i, 1); textView2.setText(String.format(Locale.getDefault(), "%02d:%02d:%02d", time / 3600, (time % 3600) / 60, (time % 60))); textView3.setText(DateFormat.getDateInstance(DateFormat.SHORT).format(scores.getHighScore(i, 2))); textView4.setText(new SimpleDateFormat("HH:mm", Locale.getDefault()).format(scores.getHighScore(i, 2))); tableLayout.addView(row); } return view; }
From source file:de.tobiasbielefeld.solitaire.ui.statistics.RecentScoresFragment.java
/** * Loads the high score list//from w ww .j a v a2s .c om */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_statistics_tab3, container, false); //if the app got killed while the statistics are open and then the user restarts the app, //my helper classes aren't initialized so they can't be used. In this case, simply //close the statistics try { loadData(); } catch (NullPointerException e) { getActivity().finish(); return view; } TableLayout tableLayout = (TableLayout) view.findViewById(R.id.statisticsTableHighScores); TextView textNoEntries = (TextView) view.findViewById(R.id.statisticsTextNoEntries); if (scores.getRecentScore(0, 2) != 0) { textNoEntries.setVisibility(View.GONE); } for (int i = 0; i < Scores.MAX_SAVED_SCORES; i++) { //for each entry in highScores, add a new view with it if (scores.getRecentScore(i, 2) == 0) { //if the score is zero, don't show it continue; } TableRow row = (TableRow) LayoutInflater.from(getContext()).inflate(R.layout.statistics_scores_row, null); TextView textView1 = (TextView) row.findViewById(R.id.row_cell_1); TextView textView2 = (TextView) row.findViewById(R.id.row_cell_2); TextView textView3 = (TextView) row.findViewById(R.id.row_cell_3); TextView textView4 = (TextView) row.findViewById(R.id.row_cell_4); textView1.setText(String.format(Locale.getDefault(), "%s %s", scores.getRecentScore(i, 0), dollar)); long time = scores.getRecentScore(i, 1); textView2.setText(String.format(Locale.getDefault(), "%02d:%02d:%02d", time / 3600, (time % 3600) / 60, (time % 60))); textView3.setText(DateFormat.getDateInstance(DateFormat.SHORT).format(scores.getRecentScore(i, 2))); textView4.setText( new SimpleDateFormat("HH:mm", Locale.getDefault()).format(scores.getRecentScore(i, 2))); tableLayout.addView(row); } return view; }
From source file:nl.tompeerdeman.ahd.highsore.HighScoreFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = (TableLayout) inflater.inflate(R.layout.fragment_highscore, container, false); TableLayout rootTable = (TableLayout) root.findViewById(R.id.highscoreTableLayout); TableRow row; TextView tView;//from ww w . ja va 2 s . c o m row = (TableRow) inflater.inflate(R.layout.tablerow, rootTable, false); tView = (TextView) row.findViewById(R.id.table_word); tView.setText("Word"); tView = (TextView) row.findViewById(R.id.table_badguesses); tView.setText("Bad guesses"); tView = (TextView) row.findViewById(R.id.table_time); tView.setText("Time"); rootTable.addView(row); highScoresModel.ensureLoaded(); List<HighScoreEntry> entries; switch (type) { case 0: entries = highScoresModel.getHighScoresEvil(); break; case 1: entries = highScoresModel.getHighScoresNormal(); break; case 2: entries = highScoresModel.getHighScoresAll(); break; default: entries = Collections.emptyList(); } for (HighScoreEntry entry : entries) { row = (TableRow) inflater.inflate(R.layout.tablerow, rootTable, false); tView = (TextView) row.findViewById(R.id.table_word); tView.setText(entry.getWord()); tView = (TextView) row.findViewById(R.id.table_badguesses); tView.setText(String.valueOf(entry.getBadGuesses())); tView = (TextView) row.findViewById(R.id.table_time); tView.setText(TIME_FORMAT.format(new Date(entry.getTime()))); rootTable.addView(row); } if (entries.size() == 0) { row = (TableRow) inflater.inflate(R.layout.tablerow, rootTable, false); tView = (TextView) row.findViewById(R.id.table_word); tView.setText("No entries"); rootTable.addView(row); } return root; }
From source file:ca.ualberta.cmput301.t03.trading.toptraders.TopTradersFragment.java
private void refreshTopTradersUI() { Activity activity = getActivity();/* w w w . j a v a2 s. c o m*/ if (activity != null) { activity.runOnUiThread(new Runnable() { @Override public void run() { topTradersLayout.removeAllViews(); for (TopTrader trader : topTraders) { TableRow row = (TableRow) LayoutInflater.from(TopTradersFragment.this.getContext()) .inflate(R.layout.attrib_row, null); ((TextView) row.findViewById(R.id.attrib_name)).setText(trader.getUserName()); ((TextView) row.findViewById(R.id.attrib_value)) .setText(trader.getSuccessfulTradeCount().toString()); topTradersLayout.addView(row); } swipeRefreshLayout.setRefreshing(false); } }); } }
From source file:com.bonsai.btcreceive.AccountFragment.java
private void addAddressHeader(TableLayout table) { TableRow row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.address_table_header, table, false);/* www. j a v a 2 s .co m*/ TextView tv = (TextView) row.findViewById(R.id.header_btc); tv.setText(BaseWalletActivity.getBTCFmt().unitStr()); table.addView(row); }
From source file:com.bonsai.btcreceive.TransactionsFragment.java
private void addTransactionHeader(TableLayout table) { TableRow row = (TableRow) LayoutInflater.from(getActivity()).inflate(R.layout.transaction_table_header, table, false);//from w ww .j a va 2 s . c o m TextView tv = (TextView) row.findViewById(R.id.header_btc); tv.setText(BaseWalletActivity.getBTCFmt().unitStr()); table.addView(row); }
From source file:se.frikod.payday.DailyBudgetFragment.java
private void updateBudgetItems() { TableLayout itemsTable = (TableLayout) V.findViewById(R.id.budgetItems); itemsTable.removeAllViews();/*from w w w. ja v a 2 s.c o m*/ for (int i = 0; i < budget.budgetItems.size(); i++) { BudgetItem bi = budget.budgetItems.get(i); final int currentIndex = i; LayoutInflater inflater = activity.getLayoutInflater(); TableRow budgetItemView = (TableRow) inflater.inflate(R.layout.daily_budget_budget_item, itemsTable, false); TextView amount = (TextView) budgetItemView.findViewById(R.id.budgetItemAmount); TextView title = (TextView) budgetItemView.findViewById(R.id.budgetItemLabel); amount.setText(budget.formatter.format(bi.amount)); title.setText(bi.title); if (bi.exclude) { amount.setTextColor(0xffCCCCCC); amount.setPaintFlags(amount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); title.setTextColor(0xffCCCCCC); title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); } budgetItemView.setClickable(true); budgetItemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(10); BudgetItem bi = budget.budgetItems.get(currentIndex); bi.exclude = !bi.exclude; budget.saveBudgetItems(); updateBudgetItems(); } }); budgetItemView.setLongClickable(true); budgetItemView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { editBudgetItem(v, currentIndex); return true; } }); itemsTable.addView(budgetItemView); } FontUtils.setRobotoFont(activity, itemsTable); updateBudget(); }
From source file:de.damdi.fitness.activity.start_training.DialogFragmentTrainingEntryTable.java
@SuppressLint("SimpleDateFormat") @Override// w w w . ja va 2s .c om public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = LayoutInflater.from(getActivity()); final View v = inflater.inflate(R.layout.dialog_training_entry_table, null); TableLayout table = (TableLayout) v.findViewById(R.id.table_training_entry); DateFormat dateformat = new SimpleDateFormat("dd.MM"); boolean odd = false; Iterator<TrainingEntry> it = mFex.getTrainingEntryList().iterator(); int entry_count = 0; while (it.hasNext()) { TrainingEntry entry = it.next(); for (FSet set : entry.getFSetList()) { TableRow row; if (odd) { row = (TableRow) inflater.inflate(R.layout.row_type_1, null); } else { row = (TableRow) inflater.inflate(R.layout.row_type_2, null); } odd = !odd; TextView text_view_date = (TextView) row.findViewById(R.id.text_view_date); text_view_date.setText(dateformat.format(entry.getDate())); for (SetParameter parameter : set.getSetParameters()) { TextView text_view_duration = (TextView) row.findViewById(R.id.text_view_duration); TextView text_view_rep = (TextView) row.findViewById(R.id.text_view_rep); TextView text_view_weigh = (TextView) row.findViewById(R.id.text_view_weigh); if (parameter instanceof SetParameter.Duration) { text_view_duration.setText(parameter.toString()); } if (parameter instanceof SetParameter.Repetition) { text_view_rep.setText(parameter.toString()); } if (parameter instanceof SetParameter.Weight) { text_view_weigh.setText(parameter.toString()); } } entry_count++; table.addView(row); } // only append diver row(=just a black row) if there are more rows if (it.hasNext()) { TableRow row_empty = (TableRow) inflater.inflate(R.layout.row_type_empty_row, null); table.addView(row_empty); } } if (entry_count == 0) { return new AlertDialog.Builder(getActivity()).setMessage(getString(R.string.no_other_training_entries)) .setPositiveButton(getString(android.R.string.ok), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).setCancelable(true).create(); } return new AlertDialog.Builder(getActivity()).setView(v).setCancelable(false).create(); }
From source file:com.bonsai.wallet32.MainActivity.java
private void addBalanceHeader(TableLayout table) { TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.balance_table_header, table, false); TextView tv = (TextView) row.findViewById(R.id.header_btc); tv.setText(mBTCFmt.unitStr());/*from ww w. java 2 s . co m*/ table.addView(row); }
From source file:com.bonsai.wallet32.MainActivity.java
private void addBalanceRow(TableLayout table, int accountId, String acct, long btc, double fiat) { TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.balance_table_row, table, false); Button tv0 = (Button) row.findViewById(R.id.row_label); tv0.setId(accountId);/* w w w . j av a 2 s . com*/ tv0.setText(acct); TextView tv1 = (TextView) row.findViewById(R.id.row_btc); tv1.setText(mBTCFmt.formatCol(btc, 0, true, true)); TextView tv2 = (TextView) row.findViewById(R.id.row_fiat); tv2.setText(String.format("%.02f", fiat)); table.addView(row); }