List of usage examples for android.widget TableRow getChildAt
public View getChildAt(int index)
From source file:com.mikecorrigan.trainscorekeeper.FragmentSummary.java
private void updateUi() { Log.vc(VERBOSE, TAG, "updateUi"); if (game == null) { Log.w(TAG, "updateUi: no game, this=" + this); return;//from ww w. j a v a 2 s . c om } if (tableLayout == null) { Log.w(TAG, "updateUi: no table, this=" + this); return; } // Subtract one to skip the header in the allocation. final int numRows = tableLayout.getChildCount() - 1; final TableRow headerRow = (TableRow) tableLayout.getChildAt(0); final int numCols = headerRow.getChildCount(); String[] header = new String[numCols]; int[][] scores = new int[numRows][numCols]; game.getSummary(header, scores); for (int c = 0; c < numCols; c++) { TextView textView = (TextView) headerRow.getChildAt(c); textView.setText(header[c]); } for (int r = 0; r < numRows; r++) { // Add one to the row index to skip the header. final TableRow row = (TableRow) tableLayout.getChildAt(r + 1); for (int c = 0; c < numCols; c++) { TextView textView = (TextView) row.getChildAt(c); textView.setText(Integer.toString(scores[r][c])); } } }
From source file:aws.apps.underthehood.Main.java
private void changeFontSize(TableLayout t, float fontSize) { for (int i = 0; i <= t.getChildCount() - 1; i++) { TableRow row = (TableRow) t.getChildAt(i); for (int j = 0; j <= row.getChildCount() - 1; j++) { View v = row.getChildAt(j); try { if (v.getClass() == Class.forName("android.widget.TextView")) { TextView tv = (TextView) v; if (i % 2 == 0) { } else { tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize); }// w w w. j a v a 2 s.com } } catch (Exception e) { Log.e(TAG, "^ changeFontSize: "); } } } }
From source file:com.example.parkhere.seeker.SeekerProfileVehicleFragment.java
private void selectRow(int index) { if (index != selectedIndex) { if (selectedIndex >= 0) { deselectRow(selectedIndex);//from w w w. j a v a 2 s . c om } TableRow tr = (TableRow) tl.findViewWithTag(index); tr.setBackgroundColor(Color.LTGRAY); selectedIndex = index; TextView tv = (TextView) tr.getChildAt(0); selectedMake = tv.getText().toString(); tv = (TextView) tr.getChildAt(1); selectedModel = tv.getText().toString(); tv = (TextView) tr.getChildAt(2); selectedLicensePlate = tv.getText().toString(); Vehicle v = getVehicle(selectedLicensePlate); sprof_make.setText(v.getMake()); sprof_model.setText(v.getModel()); sprof_color.setText(v.getColor()); sprof_year.setText(v.getYear()); sprof_licenseplate.setText(v.getLicensePlate()); } }
From source file:com.example.parkhere.seeker.SeekerProfileVehicleFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { user = (User) getArguments().getSerializable(USER_KEY); vehicles = (Vehicle[]) getArguments().getSerializable(SEEKER_VEHICLES_KEY); getCurrInfo();// w w w. j a v a2s . c om rootView = inflater.inflate(R.layout.fragment_seeker_profile_vehicle, container, false); sprof_make = (EditText) rootView.findViewById(R.id.sprof_make); sprof_model = (EditText) rootView.findViewById(R.id.sprof_model); sprof_color = (EditText) rootView.findViewById(R.id.sprof_color); sprof_year = (EditText) rootView.findViewById(R.id.sprof_year); sprof_licenseplate = (EditText) rootView.findViewById(R.id.sprof_licenseplate); tl = (TableLayout) rootView.findViewById(R.id.sprof_vehicle_table); sprof_add_vehicle_button = (Button) rootView.findViewById(R.id.sprof_add_vehicle_button); sprof_edit_vehicle_button = (Button) rootView.findViewById(R.id.sprof_edit_vehicle_button); sprof_delete_vehicle_button = (Button) rootView.findViewById(R.id.sprof_delete_vehicle_button); sprof_add_vehicle_button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { String make = sprof_make.getText().toString(); String model = sprof_model.getText().toString(); String color = sprof_color.getText().toString(); String year = sprof_year.getText().toString(); String licensePlate = sprof_licenseplate.getText().toString(); Vehicle vehicle = new Vehicle(); vehicle.setMake(make); vehicle.setModel(model); vehicle.setColor(color); vehicle.setYear(year); vehicle.setLicensePlate(licensePlate); if (!validate(vehicle)) { onAddUpdateVehicleFailed(); return; } Vehicle v = getVehicle(licensePlate); if (v.getMake() == null) { addVehicle(vehicle); } else { Snackbar.make(rootView, "Vehicle with this license plate already exists; cannot re-add", Snackbar.LENGTH_LONG).show(); } } }); sprof_edit_vehicle_button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (selectedMake.equals("")) { Snackbar.make(rootView, "Must select a vehicle", Snackbar.LENGTH_LONG).show(); } else { String make = sprof_make.getText().toString(); String model = sprof_model.getText().toString(); String color = sprof_color.getText().toString(); String year = sprof_year.getText().toString(); String licensePlate = sprof_licenseplate.getText().toString(); Vehicle vehicle = new Vehicle(); vehicle.setMake(make); vehicle.setModel(model); vehicle.setColor(color); vehicle.setYear(year); vehicle.setLicensePlate(licensePlate); if (!validate(vehicle)) { onAddUpdateVehicleFailed(); return; } else if (!licensePlate.equals(selectedLicensePlate)) { Snackbar.make(rootView, "Cannot update vehicle license plate; add a new vehicle with this license plate", Snackbar.LENGTH_LONG).show(); } else { vehicles[selectedIndex - 1] = vehicle; TableRow tr = (TableRow) tl.findViewWithTag(selectedIndex); tr.setBackgroundColor(Color.LTGRAY); TextView tv = (TextView) tr.getChildAt(0); tv.setText(vehicle.getMake()); tv = (TextView) tr.getChildAt(1); tv.setText(vehicle.getModel()); editVehicle(); } } } }); sprof_delete_vehicle_button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (selectedMake.equals("")) { Snackbar.make(rootView, "Must select a vehicle", Snackbar.LENGTH_LONG).show(); } else if (tag == 2) { Snackbar.make(rootView, "Must add another vehicle before deleting your only listed vehicle", Snackbar.LENGTH_LONG).show(); } else { LayoutInflater li = LayoutInflater.from(myContext); View customView = li.inflate(R.layout.popup_delete_vehicle, null); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(myContext); alertDialogBuilder.setView(customView); final AlertDialog alertDialog = alertDialogBuilder.create(); TextView deleteText = (TextView) customView.findViewById(R.id.popup_delete_vehicle_text); deleteText.setText("Are you sure you want to delete this vehicle: " + selectedMake + " " + selectedModel + " " + selectedLicensePlate + "?"); ImageButton closeButton = (ImageButton) customView .findViewById(R.id.popup_delete_vehicle_close); closeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { alertDialog.dismiss(); } }); Button deleteButton = (Button) customView.findViewById(R.id.popup_delete_vehicle_button); deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { deleteVehicle(); alertDialog.dismiss(); } }); alertDialog.show(); } } }); return rootView; }
From source file:com.retroteam.studio.retrostudio.MeasureEditor.java
/** * Assign a note visually and in the project. * @param view/*from ww w . ja v a 2s . co m*/ */ private void paintNote(View view) { com.getbase.floatingactionbutton.FloatingActionButton ptool = (com.getbase.floatingactionbutton.FloatingActionButton) findViewById( R.id.pencilTool); ImageView iview = (ImageView) view; Drawable notestatus = iview.getDrawable(); if (pencil) { if (notestatus.getConstantState().equals(ContextCompat .getDrawable(getApplicationContext(), R.drawable.note_filled).getConstantState())) { //blank all other notes in the column TableRow parent = (TableRow) iview.getParent(); TableLayout layoutparent = (TableLayout) parent.getParent(); int notedrawlen = layoutparent.getChildCount(); for (int x = 0; x < notedrawlen; x++) { TableRow noterow = (TableRow) layoutparent.getChildAt(x); for (int i = 0; i < noterow.getChildCount(); i++) { ImageView note = (ImageView) noterow.getChildAt(i); if (note.getTag(R.id.TAG_COLUMN) == iview.getTag(R.id.TAG_COLUMN)) { note.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline)); for (int n = 0; n < filledNotes.size(); n++) { int[] comp = filledNotes.get(n); if (comp[0] == (int) note.getTag(R.id.TAG_ROW) && comp[1] == (int) note.getTag(R.id.TAG_COLUMN)) { filledNotes.remove(n); } } } } } //set the drawable iview.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline)); filledNotes.remove( new int[] { (int) iview.getTag(R.id.TAG_ROW), (int) iview.getTag(R.id.TAG_COLUMN) }); // set the other notes to rests List<Integer> guiSNAPRange = (List<Integer>) iview.getTag(R.id.TAG_GUISNAPRANGE); for (int z = guiSNAPRange.get(0); z <= guiSNAPRange.get(guiSNAPRange.size() - 1); z++) { theproject.track(trackNum).measure(measureNum).replace(z, new Note(Note.REST, noteSUB)); } } else { //blank all other notes in the column TableRow parent = (TableRow) iview.getParent(); TableLayout layoutparent = (TableLayout) parent.getParent(); int notedrawlen = layoutparent.getChildCount(); for (int x = 0; x < notedrawlen; x++) { TableRow noterow = (TableRow) layoutparent.getChildAt(x); for (int i = 0; i < noterow.getChildCount(); i++) { ImageView note = (ImageView) noterow.getChildAt(i); if (note.getTag(R.id.TAG_COLUMN) == iview.getTag(R.id.TAG_COLUMN)) { note.setImageDrawable( ContextCompat.getDrawable(getApplicationContext(), R.drawable.measure_outline)); for (int n = 0; n < filledNotes.size(); n++) { int[] comp = filledNotes.get(n); if (comp[0] == (int) note.getTag(R.id.TAG_ROW) && comp[1] == (int) note.getTag(R.id.TAG_COLUMN)) { filledNotes.remove(n); } } } } } //set the drawable iview.setImageDrawable(ContextCompat.getDrawable(getApplicationContext(), R.drawable.note_filled)); filledNotes .add(new int[] { (int) iview.getTag(R.id.TAG_ROW), (int) iview.getTag(R.id.TAG_COLUMN) }); //set the note in the data structure double notetype = stringToNoteDouble((String) iview.getTag(R.id.TAG_NOTE)); List<Integer> guiSNAPRange = (List<Integer>) iview.getTag(R.id.TAG_GUISNAPRANGE); for (int z = guiSNAPRange.get(0); z <= guiSNAPRange.get(guiSNAPRange.size() - 1); z++) { theproject.track(trackNum).measure(measureNum).replace(z, new Note(notetype, noteSUB)); } } } }
From source file:com.github.akinaru.rfdroid.activity.BtDevicesActivity.java
public void altTableRow(int alt_row) { int childViewCount = tablelayout.getChildCount(); for (int i = 0; i < childViewCount; i++) { TableRow row = (TableRow) tablelayout.getChildAt(i); for (int j = 0; j < row.getChildCount(); j++) { TextView tv = (TextView) row.getChildAt(j); if (i % alt_row != 0) { tv.setBackground(getResources().getDrawable(R.drawable.alt_row_color)); } else { tv.setBackground(getResources().getDrawable(R.drawable.row_color)); }//from ww w. j a v a2s . c o m } } }
From source file:com.cybrosys.currency.CurrencyMain.java
public void onStart() { super.onStart(); getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM, WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); linlaHeaderProgress = (LinearLayout) getView().findViewById(R.id.linlaHeaderProgress); imgvHead = (ImageView) getView().findViewById(R.id.imageHead); txtvHead = (TextView) getView().findViewById(R.id.textHead); lstvMainlistView = (ListView) getView().findViewById(R.id.listview); etxtText = (EditText) getView().findViewById(R.id.editText1); slide = (SlidingDrawer) getView().findViewById(R.id.SlidingDrawer); TableLayout tablePad = (TableLayout) getView().findViewById(R.id.tablone); int inPadCount = tablePad.getChildCount(); for (int i = 0; i < inPadCount; i++) { View v = tablePad.getChildAt(i); if (v instanceof TableRow) { TableRow row = (TableRow) v; int rowCount = row.getChildCount(); for (int r = 0; r < rowCount; r++) { View v2 = row.getChildAt(r); if (v2 instanceof Button) { Button b = (Button) v2; b.setOnClickListener(buttonpad); } else if (v2 instanceof TextView) { TextView txtv = (TextView) v2; txtv.setOnClickListener(null); }// w w w . java2s .c o m } } } isFlag2 = true; Settings = getActivity().getSharedPreferences(strPREFERNAME, 0); for (int inI = 0; inI <= 5; inI++) { if (Settings.getString("val" + inI, "").equals("") && Settings.getString("CrnCode" + inI, "").equals("") && Settings.getString("flag" + inI, "").equals("")) { isFlag2 = false; } } if (isFlag2 == true) { Sharepreferences(); } else { CustomListView(); if (isConnection() == true) { } else { isFlag2 = true; isFlag = true; Toast.makeText(getActivity(), "No Internet Conection", Toast.LENGTH_LONG).show(); } } SharedPreferences prefs = PalmCalcActivity.ctx.getSharedPreferences("UpdateTime", 0); lastUpdateTime = prefs.getLong("lastUpdateTime", 0); if ((lastUpdateTime) <= System.currentTimeMillis()) { lastUpdateTime = System.currentTimeMillis(); SharedPreferences.Editor editors = prefs.edit(); editors.putLong("lastUpdateTime", lastUpdateTime); editors.commit(); if (isConnection() == true) { new BackProsess().execute(getActivity()); } } etxtText.addTextChangedListener(textwach); aList = new ArrayList<HashMap<String, String>>(); for (int InI = 0; InI < 5; InI++) { hm = new HashMap<String, String>(); hm.put("flag", Integer.toString(fltFlags[InI])); if (InI != 5) { hm.put("cur", strCrnCode[InI].substring(0, 3)); } else { hm.put("cur", strCrnCode[InI]); } aList.add(hm); } txtvHead.setText(strCrnCode[5]); imgvHead.setImageResource(fltFlags[5]); adapter = new ListAdapter1(getActivity(), aList); lstvMainlistView.setAdapter(adapter); lstvMainlistView.setOnItemClickListener(ListsingleClick); lstvMainlistView.setOnItemLongClickListener(ListLongClick); Decimalpoint(); View vwMain = (View) getActivity().findViewById(R.id.idCurrencyMain); vwMain.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { slide.close(); return true; } }); etxtText.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!slide.isOpened()) { slide.open(); } } }); if (!Settings.getString("Input", "").equals("")) { calculation(Double.parseDouble(Settings.getString("Input", ""))); etxtText.setText(""); etxtText.setText(Settings.getString("Input", "")); } else { etxtText.setText(Settings.getString("Input", "1")); } }
From source file:com.money.manager.ex.home.DashboardFragment.java
private View showTableLayoutUpComingTransactions(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()); Core core = new Core(getActivity().getApplicationContext()); // Textview Title TextView title = (TextView) layout.findViewById(R.id.textViewTitle); title.setText(R.string.upcoming_transactions); // Table//from ww w .j a v a 2s .c om TableLayout tableLayout = (TableLayout) layout.findViewById(R.id.tableLayoutSummary); // add rows while (cursor.moveToNext()) { // load values String payee = "<i>" + cursor.getString(cursor.getColumnIndex(QueryBillDeposits.PAYEENAME)) + "</i>"; double total = cursor.getDouble(cursor.getColumnIndex(QueryBillDeposits.AMOUNT)); int daysLeft = cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.DAYSLEFT)); int currencyId = cursor.getInt(cursor.getColumnIndex(QueryBillDeposits.CURRENCYID)); String daysLeftText = ""; daysLeftText = Integer.toString(Math.abs(daysLeft)) + " " + getString(daysLeft >= 0 ? R.string.days_remaining : R.string.days_overdue); TableRow row = createTableRow( new String[] { "<small>" + payee + "</small>", "<small>" + currencyService.getCurrencyFormatted(currencyId, MoneyFactory.fromDouble(total)) + "</small>", "<small>" + daysLeftText + "</small>" }, new Float[] { 1f, null, 1f }, new Integer[] { null, Gravity.RIGHT, Gravity.RIGHT }, new Integer[][] { null, { 0, 0, padding_in_px, 0 }, null }); TextView txt = (TextView) row.getChildAt(2); UIHelper uiHelper = new UIHelper(getActivity()); int color = daysLeft >= 0 ? uiHelper.resolveAttribute(R.attr.holo_green_color_theme) : uiHelper.resolveAttribute(R.attr.holo_red_color_theme); txt.setTextColor(ContextCompat.getColor(getActivity(), color)); // Add Row tableLayout.addView(row); } // return Layout return layout; }
From source file:hongik.android.project.best.StoreReviewActivity.java
public void drawTable() throws Exception { String query = "func=morereview" + "&license=" + license; DBConnector conn = new DBConnector(query); conn.start();/*from w w w.java2 s.c om*/ conn.join(); JSONObject jsonResult = conn.getResult(); boolean result = jsonResult.getBoolean("result"); if (!result) { return; } String storeName = jsonResult.getString("sname"); ((TextViewPlus) findViewById(R.id.storereview_storename)).setText(storeName); JSONArray review = null; if (!jsonResult.isNull("review")) { review = jsonResult.getJSONArray("review"); } //Draw Review Table if (review != null) { TableRow motive = (TableRow) reviewTable.getChildAt(1); for (int i = 0; i < review.length(); i++) { JSONObject json = review.getJSONObject(i); final String[] elements = new String[4]; elements[0] = Double.parseDouble(json.getString("GRADE")) + ""; elements[1] = json.getString("NOTE"); elements[2] = json.getString("CID#"); elements[3] = json.getString("DAY"); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[4]; if (elements[1].length() > 14) elements[1] = elements[1].substring(0, 14) + "..."; for (int j = 0; j < 4; j++) { tbCols[j] = new TextViewPlus(this); tbCols[j].setText(elements[j]); tbCols[j].setLayoutParams(motive.getChildAt(j).getLayoutParams()); tbCols[j].setGravity(Gravity.CENTER); tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(), "InterparkGothicBold.ttf")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent reviewIntent = new Intent(originActivity, ReviewDetailActivity.class); reviewIntent.putExtra("ACCESS", "STORE"); reviewIntent.putExtra("CID", elements[2]); reviewIntent.putExtra("LICENSE", license); Log.i("StoreReview", "StartActivity"); startActivity(reviewIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } reviewTable.addView(tbRow); } } reviewTable.removeViewAt(1); }
From source file:com.nearnotes.NoteEdit.java
public void toggleChecklist() { if (mChecklist) { Toast.makeText(getActivity(), "Checklist off", Toast.LENGTH_SHORT).show(); mChecklist = false;// w w w. ja va 2 s. c o m mTblAddLayout.removeAllViews(); mBodyText.removeTextChangedListener(bodyTextWatcher); Spannable spannable = (Spannable) mBodyText.getText(); Object spansToRemove[] = spannable.getSpans(0, spannable.length(), Object.class); for (Object span : spansToRemove) { if (span instanceof CharacterStyle) spannable.removeSpan(span); } } else { Toast.makeText(getActivity(), "Checklist on", Toast.LENGTH_SHORT).show(); mChecklist = true; mBodyText.addTextChangedListener(bodyTextWatcher); String tempBoxes = mBodyText.getText().toString(); if (mBodyText.getLayout() != null) { mRealRow = populateBoxes(tempBoxes); int row = 0; for (NoteRow line : mRealRow) { switch (line.getType()) { case 0: TableRow inflate = (TableRow) View.inflate(getActivity(), R.layout.table_row_invisible, null); mTblAddLayout.addView(inflate); break; case 1: TableRow checkRow = (TableRow) View.inflate(getActivity(), R.layout.table_row, null); CheckBox temp = (CheckBox) checkRow.getChildAt(0); temp.setTag(Integer.valueOf(row)); mTblAddLayout.addView(checkRow); temp.setOnClickListener(checkBoxListener); break; case 2: TableRow checkRow1 = (TableRow) View.inflate(getActivity(), R.layout.table_row, null); CheckBox temp1 = (CheckBox) checkRow1.getChildAt(0); temp1.setTag(Integer.valueOf(row)); temp1.setChecked(true); mTblAddLayout.addView(checkRow1); temp1.setOnClickListener(checkBoxListener); break; } for (int k = 1; line.getSize() > k; k++) { TableRow inflate = (TableRow) View.inflate(getActivity(), R.layout.table_row_invisible, null); mTblAddLayout.addView(inflate); } row++; } } } }