List of usage examples for android.widget TableLayout addView
@Override public void addView(View child)
From source file:com.windnow.StationTextActivity.java
@SuppressLint("RtlHardcoded") private void printTableRow(String line) { TableLayout tl = (TableLayout) findViewById(R.id.tableLayout); String[] words = line.split("&/"); TableRow tr = new TableRow(this); TableRow.LayoutParams params = new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);//from ww w.j a va 2 s.c om params.gravity = Gravity.FILL_HORIZONTAL; tr.setLayoutParams(params); TableRow.LayoutParams tvParams = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); tvParams.setMargins(0, 0, 6, 0); for (int i = words.length - 1; i >= 0; i--) { TextView txv = new TextView(this); txv.setLayoutParams(tvParams); txv.setText(words[i]); txv.setGravity(i == 0 ? Gravity.LEFT : Gravity.LEFT); tr.addView(txv, 0); } tl.addView(tr); }
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);//from ww w.j av a 2s .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); }
From source file:org.mklab.mikity.android.editor.AbstractObjectEditor.java
private void createRotationBoxes(TableLayout parameters) { final RotationModel rotation = this.object.getRotation(); final String x; final String y; final String z; if (rotation != null) { x = "" + rotation.getX(); //$NON-NLS-1$ y = "" + rotation.getY(); //$NON-NLS-1$ z = "" + rotation.getZ(); //$NON-NLS-1$ } else {//from w ww. ja v a 2 s .co m x = "0"; //$NON-NLS-1$ y = "0"; //$NON-NLS-1$ z = "0"; //$NON-NLS-1$ } this.rotationX = new ParameterInputBox(getContext(), this, this); parameters.addView(this.rotationX); this.rotationX.setName(R.string.rotation_wrt_x_axis); this.rotationX.setValue(x); this.rotationX.setUnit("[rad]"); //$NON-NLS-1$ this.rotationY = new ParameterInputBox(getContext(), this, this); parameters.addView(this.rotationY); this.rotationY.setName(R.string.rotation_wrt_y_axis); this.rotationY.setValue(y); this.rotationY.setUnit("[rad]"); //$NON-NLS-1$ this.rotationZ = new ParameterInputBox(getContext(), this, this); parameters.addView(this.rotationZ); this.rotationZ.setName(R.string.rotation_wrt_z_axis); this.rotationZ.setValue(z); this.rotationZ.setUnit("[rad]"); //$NON-NLS-1$ }
From source file:de.uulm.graphicalpasswords.opentapi.TAPILoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tapi_login); // Show the Up button in the action bar. setupActionBar();//w ww . ja v a2 s . c om SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); length = Integer.parseInt(sharedPref.getString("tapi_length", "6")); password = sharedPref.getString("tapi_pw", ""); input = new String[length]; for (int i = 0; i < images.length; i++) { images[i] = sharedPref.getInt("image" + i, 0); } EditText editText = (EditText) findViewById(R.id.tapi_edittext); text = editText.getText(); back = (Button) findViewById(R.id.tapi_back); clear = (Button) findViewById(R.id.tapi_clear); save = (Button) findViewById(R.id.tapi_save); TableLayout table = (TableLayout) findViewById(R.id.tapi_imagetable); LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); TableRow row = null; for (int i = 0; i < imageViews.length; i++) { if (i % 4 == 0) { row = new TableRow(this); } imageViews[i] = new PassImageView(this); imageViews[i].setLayoutParams(layoutParams); imageViews[i].setAdjustViewBounds(true); imageViews[i].setScaleType(ScaleType.CENTER_INSIDE); imageViews[i].setPadding(5, 5, 5, 5); imageViews[i].setImageResource(images[i]); row.addView(imageViews[i]); if (i % 4 == 3) { table.addView(row); } imageViews[i].setOnTouchListener(new TAPIOnTouchListener(this, imageViews[i])); } }
From source file:org.mklab.mikity.android.editor.AbstractObjectEditor.java
private void createTranslationBoxes(TableLayout parameters) { final TranslationModel translation = this.object.getTranslation(); final String x; final String y; final String z; if (translation != null) { x = "" + translation.getX(); //$NON-NLS-1$ y = "" + translation.getY(); //$NON-NLS-1$ z = "" + translation.getZ(); //$NON-NLS-1$ } else {/* w ww . ja v a 2 s . c om*/ x = "0"; //$NON-NLS-1$ y = "0"; //$NON-NLS-1$ z = "0"; //$NON-NLS-1$ } this.translationX = new ParameterInputBox(getContext(), this, this); parameters.addView(this.translationX); this.translationX.setName(R.string.translation_to_x_axis); this.translationX.setValue(x); this.translationX.setUnit("[m]"); //$NON-NLS-1$ this.translationY = new ParameterInputBox(getContext(), this, this); parameters.addView(this.translationY); this.translationY.setName(R.string.translation_to_y_axis); this.translationY.setValue(y); this.translationY.setUnit("[m]"); //$NON-NLS-1$ this.translationZ = new ParameterInputBox(getContext(), this, this); parameters.addView(this.translationZ); this.translationZ.setName(R.string.translation_to_z_axis); this.translationZ.setValue(z); this.translationZ.setUnit("[m]"); //$NON-NLS-1$ }
From source file:org.smap.smapTask.android.activities.TaskAddressActivity.java
/** Called when the activity is first created. */ @Override/*from ww w. j a v a 2 s . c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.task_address); // Get the id of the selected list item Bundle bundle = getIntent().getExtras(); taskEntry = Utilities.getTaskWithId(bundle.getLong("id")); try { //String assignment_status = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_STATUS)); //String taskTitle = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_TITLE)); //String taskAddress = c.getString(c.getColumnIndex(FileDbAdapter.KEY_T_ADDRESS)); // Formatting LinearLayout.LayoutParams textLayout = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); textLayout.setMargins(1, 1, 1, 1); TableRow.LayoutParams trLayout = new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); trLayout.setMargins(1, 1, 1, 1); TableLayout tableLayout = (TableLayout) findViewById(R.id.task_address_values); // Add Title TextView title = (TextView) findViewById(R.id.task_title); title.setText(taskEntry.name); // Add Status TableRow r = new TableRow(this); r.setLayoutParams(trLayout); r.setBackgroundColor(0xff0000); TextView text1 = new TextView(this); text1.setText("Status"); text1.setBackgroundColor(0xff0000); TextView text2 = new TextView(this); text2.setText(taskEntry.taskStatus); text2.setBackgroundColor(0xff0000); r.addView(text1); r.addView(text2); tableLayout.addView(r); // Put the Address items in the table Type type = new TypeToken<ArrayList<Address>>() { }.getType(); ArrayList<Address> aArray = new Gson().fromJson(taskEntry.taskAddress, type); if (aArray != null) { for (int i = 0; i < aArray.size(); i++) { r = new TableRow(this); r.setLayoutParams(trLayout); r.setBackgroundColor(0xff0000); text1 = new TextView(this); text1.setText(aArray.get(i).name); text1.setBackgroundColor(0xff0000); text2 = new TextView(this); text2.setText(aArray.get(i).value); text2.setBackgroundColor(0xff0000); r.addView(text1); r.addView(text2); tableLayout.addView(r); } } // Create the buttons LinearLayout buttons = (LinearLayout) findViewById(R.id.task_address_buttons); //menu.setHeaderTitle(taskTitle); if (Utilities.canReject(taskEntry.taskStatus)) { Button b = new Button(this); b.setText("Reject Task"); b.setId(R.id.reject_button); b.setOnClickListener(this); buttons.addView(b); } if (Utilities.canComplete(taskEntry.taskStatus)) { Button b = new Button(this); b.setText("Complete Task"); b.setId(R.id.complete_button); b.setOnClickListener(this); buttons.addView(b); } } catch (Exception e) { e.printStackTrace(); } }
From source file:de.uulm.graphicalpasswords.opentapi.TAPICreatePasswordActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tapi_create_password); // Show the Up button in the action bar. setupActionBar();/* w w w .jav a 2 s.c o m*/ SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); length = Integer.parseInt(sharedPref.getString("tapi_length", "6")); input = new String[length]; // Save Pictures in randomized order SharedPreferences.Editor editor = sharedPref.edit(); Random random = new Random(System.currentTimeMillis()); boolean[] usedImages = new boolean[TAPIActivity.IMAGES.length]; Arrays.fill(usedImages, false); for (int i = 0; i < TAPIActivity.IMAGES.length; i++) { boolean pictureSet = false; int index = random.nextInt(TAPIActivity.IMAGES.length); do { if (!usedImages[index]) { editor.putInt("image" + i, TAPIActivity.IMAGES[index]); pictureSet = true; usedImages[index] = true; } else if (index == TAPIActivity.IMAGES.length - 1) { index = 0; } else { index++; } } while (!pictureSet); } editor.commit(); for (int i = 0; i < images.length; i++) { images[i] = sharedPref.getInt("image" + i, 0); } EditText editText = (EditText) findViewById(R.id.tapi_edittext); text = editText.getText(); back = (Button) findViewById(R.id.tapi_back); save = (Button) findViewById(R.id.tapi_save); TableLayout table = (TableLayout) findViewById(R.id.tapi_imagetable); LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); TableRow row = null; for (int i = 0; i < imageViews.length; i++) { if (i % 4 == 0) { row = new TableRow(this); } imageViews[i] = new PassImageView(this); imageViews[i].setLayoutParams(layoutParams); imageViews[i].setAdjustViewBounds(true); imageViews[i].setScaleType(ScaleType.CENTER_INSIDE); imageViews[i].setPadding(5, 5, 5, 5); imageViews[i].setImageResource(images[i]); row.addView(imageViews[i]); if (i % 4 == 3) { table.addView(row); } imageViews[i].setOnTouchListener(new TAPIOnTouchListener(this, imageViews[i])); } Bundle bundle = new Bundle(); bundle.putInt("length", length); DialogFragment intro = new IntroDialogFragment(); intro.setArguments(bundle); intro.show(getFragmentManager(), "intro"); }
From source file:org.mklab.mikity.android.editor.GroupEditor.java
private void createCoordinateParameterBoxes(final View view) { final TableLayout parameters = ((TableLayout) view.findViewById(R.id.coordinate_parameters)); parameters.removeAllViews();/* w w w.j a va 2 s . co m*/ parameters.setStretchAllColumns(true); final TableRow head = new TableRow(getContext()); final TextView name = new TextView(getContext()); name.setText(R.string.name); name.setTextColor(Color.BLACK); final TextView value = new TextView(getContext()); value.setText(R.string.value); value.setTextColor(Color.BLACK); head.addView(name); head.addView(value); parameters.addView(head); createCoordinateTranslationBoxes(parameters); createCoordinateRotationBoxes(parameters); }
From source file:org.mklab.mikity.android.editor.GroupEditor.java
private void createCoordinateRotationBoxes(TableLayout parameters) { final RotationModel rotation = this.targetGroup.getRotation(); final String x; final String y; final String z; if (rotation != null) { x = "" + rotation.getX(); //$NON-NLS-1$ y = "" + rotation.getY(); //$NON-NLS-1$ z = "" + rotation.getZ(); //$NON-NLS-1$ } else {/*from ww w. j a v a 2 s . co m*/ x = "0"; //$NON-NLS-1$ y = "0"; //$NON-NLS-1$ z = "0"; //$NON-NLS-1$ } this.rotationX = new ParameterInputBox(getContext(), this, this); parameters.addView(this.rotationX); this.rotationX.setName(R.string.rotation_wrt_x_axis); this.rotationX.setValue(x); this.rotationX.setUnit(""); //$NON-NLS-1$ this.rotationY = new ParameterInputBox(getContext(), this, this); parameters.addView(this.rotationY); this.rotationY.setName(R.string.rotation_wrt_y_axis); this.rotationY.setValue(y); this.rotationY.setUnit(""); //$NON-NLS-1$ this.rotationZ = new ParameterInputBox(getContext(), this, this); parameters.addView(this.rotationZ); this.rotationZ.setName(R.string.rotation_wrt_z_axis); this.rotationZ.setValue(z); this.rotationZ.setUnit(""); //$NON-NLS-1$ }
From source file:org.mklab.mikity.android.editor.GroupEditor.java
private void createCoordinateTranslationBoxes(TableLayout parameters) { final TranslationModel translation = this.targetGroup.getTranslation(); final String x; final String y; final String z; if (translation != null) { x = "" + translation.getX(); //$NON-NLS-1$ y = "" + translation.getY(); //$NON-NLS-1$ z = "" + translation.getZ(); //$NON-NLS-1$ } else {//from w w w . j av a 2 s. c o m x = "0"; //$NON-NLS-1$ y = "0"; //$NON-NLS-1$ z = "0"; //$NON-NLS-1$ } this.translationX = new ParameterInputBox(getContext(), this, this); parameters.addView(this.translationX); this.translationX.setName(R.string.translation_to_x_axis); this.translationX.setValue(x); this.translationX.setUnit(""); //$NON-NLS-1$ this.translationY = new ParameterInputBox(getContext(), this, this); parameters.addView(this.translationY); this.translationY.setName(R.string.translation_to_y_axis); this.translationY.setValue(y); this.translationY.setUnit(""); //$NON-NLS-1$ this.translationZ = new ParameterInputBox(getContext(), this, this); parameters.addView(this.translationZ); this.translationZ.setName(R.string.translation_to_z_axis); this.translationZ.setValue(z); this.translationZ.setUnit(""); //$NON-NLS-1$ }