List of usage examples for android.widget TableRow setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.adarshahd.indianrailinfo.donate.PNRStat.java
private void createTableLayoutPsnDtls() { if (mPageResult.contains("FLUSHED PNR / ") || mPageResult.contains("Invalid PNR")) { mTextViewPNRSts.setText("The PNR entered is either invalid or expired! Please check."); mFrameLayout.removeAllViews();//from ww w . ja v a 2 s .c om mFrameLayout.addView(mTextViewPNRSts); mStrPassengerDetails = null; return; } if (mPageResult.contains("Connectivity Failure") || mPageResult.contains("try again")) { mTextViewPNRSts.setText("Looks like server is busy or currently unavailable. Please try again later!"); mFrameLayout.removeAllViews(); mFrameLayout.addView(mTextViewPNRSts); mStrPassengerDetails = null; return; } List<List<String>> passengersList; if (mPassengerDetails == null || mPassengerDetails.getPNR() != mPNRNumber) { Elements elements = Jsoup.parse(mPageResult).select("table tr td:containsOwn(S. No.)"); Iterator iterator = null; try { iterator = elements.first().parent().parent().getElementsByTag("tr").iterator(); } catch (Exception e) { Log.i("PNRStat", mPageResult); return; } passengersList = new ArrayList<List<String>>(); List<String> list; Element tmp; while (iterator.hasNext()) { tmp = (Element) iterator.next(); if (tmp.toString().contains("Passenger")) { list = new ArrayList<String>(); list.add(tmp.select("td").get(0).text()); list.add(tmp.select("td").get(1).text()); list.add(tmp.select("td").get(2).text()); if (!tmp.select("td").get(2).text().toUpperCase().contains("CNF") && !tmp.select("td").get(2).text().toUpperCase().contains("CAN")) { isWaitingList = true; } passengersList.add(list); } } mPassengerDetails = new PassengerDetails(passengersList, mPNRNumber); } else { passengersList = mPassengerDetails.getPassengerList(); } mTableLayoutPsn = new TableLayout(mActivity); TableRow row; TextView tv1, tv2, tv3, tv4; mStrPassengerDetails = new ArrayList<String>(); int current; mTableLayoutPsn.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); for (int i = 0; i < passengersList.size(); ++i) { current = i + 1; row = new TableRow(mActivity); row.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); tv1 = new TextView(mActivity); tv2 = new TextView(mActivity); tv3 = new TextView(mActivity); tv4 = new TextView(mActivity); tv1.setText("" + (i + 1) + "."); tv2.setText(" " + passengersList.get(i).get(0)); tv3.setText(" " + passengersList.get(i).get(1)); tv4.setText(" " + passengersList.get(i).get(2)); tv1.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv2.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv3.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv4.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv1.setPadding(10, 10, 10, 10); tv2.setPadding(10, 10, 10, 10); tv3.setPadding(10, 10, 10, 10); tv4.setPadding(10, 10, 10, 10); row.addView(tv1); row.addView(tv2); row.addView(tv3); row.addView(tv4); row.setBackgroundResource(R.drawable.card_background); row.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); mTableLayoutPsn.addView(row); String strPsn = "" + current + ". " + passengersList.get(i).get(0) + " " + passengersList.get(i).get(1) + " " + passengersList.get(i).get(2); mStrPassengerDetails.add(strPsn); } }
From source file:com.mifos.mifosxdroid.online.generatecollectionsheet.GenerateCollectionSheetFragment.java
private void inflateProductiveCollectionTable(CollectionSheetResponse collectionSheetResponse) { //Clear old views in case they are present. if (tableProductive.getChildCount() > 0) { tableProductive.removeAllViews(); }/*w w w. ja v a 2 s . c om*/ if (tableAdditional.getVisibility() == View.VISIBLE) { tableAdditional.removeAllViews(); tableAdditional.setVisibility(View.GONE); } //A List to be used to inflate Attendance Spinners ArrayList<String> attendanceTypes = new ArrayList<>(); attendanceTypeOptions.clear(); attendanceTypeOptions = presenter.filterAttendanceTypes(collectionSheetResponse.getAttendanceTypeOptions(), attendanceTypes); //Add the heading Row TableRow headingRow = new TableRow(getContext()); TableRow.LayoutParams headingRowParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); headingRowParams.gravity = Gravity.CENTER; headingRowParams.setMargins(0, 0, 0, 10); headingRow.setLayoutParams(headingRowParams); TextView tvGroupName = new TextView(getContext()); tvGroupName.setText(collectionSheetResponse.getGroups().get(0).getGroupName()); tvGroupName.setTypeface(tvGroupName.getTypeface(), Typeface.BOLD); tvGroupName.setGravity(Gravity.CENTER); headingRow.addView(tvGroupName); for (LoanProducts loanProduct : collectionSheetResponse.getLoanProducts()) { TextView tvProduct = new TextView(getContext()); tvProduct.setText(getString(R.string.collection_heading_charges, loanProduct.getName())); tvProduct.setTypeface(tvProduct.getTypeface(), Typeface.BOLD); tvProduct.setGravity(Gravity.CENTER); headingRow.addView(tvProduct); } TextView tvAttendance = new TextView(getContext()); tvAttendance.setText(getString(R.string.attendance)); tvAttendance.setGravity(Gravity.CENTER); tvAttendance.setTypeface(tvAttendance.getTypeface(), Typeface.BOLD); headingRow.addView(tvAttendance); tableProductive.addView(headingRow); for (ClientCollectionSheet clientCollectionSheet : collectionSheetResponse.getGroups().get(0) .getClients()) { //Insert rows TableRow row = new TableRow(getContext()); TableRow.LayoutParams rowParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); rowParams.gravity = Gravity.CENTER; rowParams.setMargins(0, 0, 0, 10); row.setLayoutParams(rowParams); //Column 1: Client Name and Id TextView tvClientName = new TextView(getContext()); tvClientName.setText( concatIdWithName(clientCollectionSheet.getClientName(), clientCollectionSheet.getClientId())); row.addView(tvClientName); //Subsequent columns: The Loan products for (LoanProducts loanProduct : collectionSheetResponse.getLoanProducts()) { //Since there may be several items in this column, create a container. LinearLayout productContainer = new LinearLayout(getContext()); productContainer.setOrientation(LinearLayout.HORIZONTAL); //Iterate through all the loans in of this type and add in the container for (LoanCollectionSheet loanCollectionSheet : clientCollectionSheet.getLoans()) { if (loanProduct.getName().equals(loanCollectionSheet.getProductShortName())) { //This loan should be shown in this column. So, add it in the container. EditText editText = new EditText(getContext()); editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); editText.setText(String.format(Locale.getDefault(), "%f", 0.0)); //Set the loan id as the Tag of the EditText which //will later be used as the identifier for this. editText.setTag(TYPE_LOAN + ":" + loanCollectionSheet.getLoanId()); productContainer.addView(editText); } } row.addView(productContainer); } Spinner spAttendance = new Spinner(getContext()); setSpinner(spAttendance, attendanceTypes); row.addView(spAttendance); tableProductive.addView(row); } if (btnSubmitProductive.getVisibility() != View.VISIBLE) { //Show the button the first time sheet is loaded. btnSubmitProductive.setVisibility(View.VISIBLE); btnSubmitProductive.setOnClickListener(this); } //If this block has been executed, that the CollectionSheet //which is already shown on screen is for center - Productive. btnSubmitProductive.setTag(TAG_TYPE_PRODUCTIVE); }
From source file:com.mifos.mifosxdroid.online.generatecollectionsheet.GenerateCollectionSheetFragment.java
private void inflateCollectionTable(CollectionSheetResponse collectionSheetResponse) { //Clear old views in case they are present. if (tableProductive.getChildCount() > 0) { tableProductive.removeAllViews(); }/* w w w . j a v a2s.c o m*/ //A List to be used to inflate Attendance Spinners ArrayList<String> attendanceTypes = new ArrayList<>(); attendanceTypeOptions.clear(); attendanceTypeOptions = presenter.filterAttendanceTypes(collectionSheetResponse.getAttendanceTypeOptions(), attendanceTypes); additionalPaymentTypeMap.clear(); additionalPaymentTypeMap = presenter.filterPaymentTypes(collectionSheetResponse.getPaymentTypeOptions(), paymentTypes); //Add the heading Row TableRow headingRow = new TableRow(getContext()); TableRow.LayoutParams headingRowParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); headingRowParams.gravity = Gravity.CENTER; headingRowParams.setMargins(0, 0, 0, 10); headingRow.setLayoutParams(headingRowParams); TextView tvGroupName = new TextView(getContext()); tvGroupName.setText(collectionSheetResponse.getGroups().get(0).getGroupName()); tvGroupName.setTypeface(tvGroupName.getTypeface(), Typeface.BOLD); tvGroupName.setGravity(Gravity.CENTER); headingRow.addView(tvGroupName); for (LoanProducts loanProduct : collectionSheetResponse.getLoanProducts()) { TextView tvProduct = new TextView(getContext()); tvProduct.setText(getString(R.string.collection_loan_product, loanProduct.getName())); tvProduct.setTypeface(tvProduct.getTypeface(), Typeface.BOLD); tvProduct.setGravity(Gravity.CENTER); headingRow.addView(tvProduct); } for (SavingsProduct savingsProduct : collectionSheetResponse.getSavingsProducts()) { TextView tvSavingProduct = new TextView(getContext()); tvSavingProduct.setText(getString(R.string.collection_saving_product, savingsProduct.getName())); tvSavingProduct.setTypeface(tvSavingProduct.getTypeface(), Typeface.BOLD); tvSavingProduct.setGravity(Gravity.CENTER); headingRow.addView(tvSavingProduct); } TextView tvAttendance = new TextView(getContext()); tvAttendance.setText(getString(R.string.attendance)); tvAttendance.setGravity(Gravity.CENTER); tvAttendance.setTypeface(tvAttendance.getTypeface(), Typeface.BOLD); headingRow.addView(tvAttendance); tableProductive.addView(headingRow); for (ClientCollectionSheet clientCollectionSheet : collectionSheetResponse.getGroups().get(0) .getClients()) { //Insert rows TableRow row = new TableRow(getContext()); TableRow.LayoutParams rowParams = new TableRow.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); rowParams.gravity = Gravity.CENTER; rowParams.setMargins(0, 0, 0, 10); row.setLayoutParams(rowParams); //Column 1: Client Name and Id TextView tvClientName = new TextView(getContext()); tvClientName.setText( concatIdWithName(clientCollectionSheet.getClientName(), clientCollectionSheet.getClientId())); row.addView(tvClientName); //Subsequent columns: The Loan products for (LoanProducts loanProduct : collectionSheetResponse.getLoanProducts()) { //Since there may be several items in this column, create a container. LinearLayout productContainer = new LinearLayout(getContext()); productContainer.setOrientation(LinearLayout.HORIZONTAL); //Iterate through all the loans in of this type and add in the container for (LoanCollectionSheet loan : clientCollectionSheet.getLoans()) { if (loanProduct.getName().equals(loan.getProductShortName())) { //This loan should be shown in this column. So, add it in the container. EditText editText = new EditText(getContext()); editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); editText.setText(String.format(Locale.getDefault(), "%f", 0.0)); //Set the loan id as the Tag of the EditText // in format 'TYPE:ID' which //will later be used as the identifier for this. editText.setTag(TYPE_LOAN + ":" + loan.getLoanId()); productContainer.addView(editText); } } row.addView(productContainer); } //After Loans, show Savings columns for (SavingsProduct product : collectionSheetResponse.getSavingsProducts()) { //Since there may be several Savings items in this column, create a container. LinearLayout productContainer = new LinearLayout(getContext()); productContainer.setOrientation(LinearLayout.HORIZONTAL); //Iterate through all the Savings in of this type and add in the container for (SavingsCollectionSheet saving : clientCollectionSheet.getSavings()) { if (saving.getProductId() == product.getId()) { //Add the saving in the container EditText editText = new EditText(getContext()); editText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL); editText.setText(String.format(Locale.getDefault(), "%f", 0.0)); //Set the Saving id as the Tag of the EditText // in 'TYPE:ID' format which //will later be used as the identifier for this. editText.setTag(TYPE_SAVING + ":" + saving.getSavingsId()); productContainer.addView(editText); } } row.addView(productContainer); } Spinner spAttendance = new Spinner(getContext()); //Set the clientId as its tag which will be used as identifier later. spAttendance.setTag(clientCollectionSheet.getClientId()); setSpinner(spAttendance, attendanceTypes); row.addView(spAttendance); tableProductive.addView(row); } if (btnSubmitProductive.getVisibility() != View.VISIBLE) { //Show the button the first time sheet is loaded. btnSubmitProductive.setVisibility(View.VISIBLE); btnSubmitProductive.setOnClickListener(this); } //If this block has been executed, that means the CollectionSheet //which is already shown is for groups. btnSubmitProductive.setTag(TAG_TYPE_COLLECTION); if (tableAdditional.getVisibility() != View.VISIBLE) { tableAdditional.setVisibility(View.VISIBLE); } //Show Additional Views TableRow rowPayment = new TableRow(getContext()); TextView tvLabelPayment = new TextView(getContext()); tvLabelPayment.setText(getString(R.string.payment_type)); rowPayment.addView(tvLabelPayment); Spinner spPayment = new Spinner(getContext()); setSpinner(spPayment, paymentTypes); rowPayment.addView(spPayment); tableAdditional.addView(rowPayment); TableRow rowAccount = new TableRow(getContext()); TextView tvLabelAccount = new TextView(getContext()); tvLabelAccount.setText(getString(R.string.account_number)); rowAccount.addView(tvLabelAccount); EditText etPayment = new EditText(getContext()); rowAccount.addView(etPayment); tableAdditional.addView(rowAccount); TableRow rowCheck = new TableRow(getContext()); TextView tvLabelCheck = new TextView(getContext()); tvLabelCheck.setText(getString(R.string.cheque_number)); rowCheck.addView(tvLabelCheck); EditText etCheck = new EditText(getContext()); rowCheck.addView(etCheck); tableAdditional.addView(rowCheck); TableRow rowRouting = new TableRow(getContext()); TextView tvLabelRouting = new TextView(getContext()); tvLabelRouting.setText(getString(R.string.routing_code)); rowRouting.addView(tvLabelRouting); EditText etRouting = new EditText(getContext()); rowRouting.addView(etRouting); tableAdditional.addView(rowRouting); TableRow rowReceipt = new TableRow(getContext()); TextView tvLabelReceipt = new TextView(getContext()); tvLabelReceipt.setText(getString(R.string.receipt_number)); rowReceipt.addView(tvLabelReceipt); EditText etReceipt = new EditText(getContext()); rowReceipt.addView(etReceipt); tableAdditional.addView(rowReceipt); TableRow rowBank = new TableRow(getContext()); TextView tvLabelBank = new TextView(getContext()); tvLabelBank.setText(getString(R.string.bank_number)); rowBank.addView(tvLabelBank); EditText etBank = new EditText(getContext()); rowBank.addView(etBank); tableAdditional.addView(rowBank); }
From source file:eu.power_switch.gui.adapter.SceneRecyclerViewAdapter.java
@Override public void onBindViewHolder(final ViewHolder holder, int position) { final Scene scene = scenes.get(holder.getAdapterPosition()); String inflaterString = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater inflater = (LayoutInflater) fragmentActivity.getSystemService(inflaterString); holder.sceneName.setText(scene.getName()); holder.sceneName.setOnClickListener(new View.OnClickListener() { @Override// w ww. j a v a 2 s . com public void onClick(View v) { if (holder.linearLayoutSceneItems.getVisibility() == View.VISIBLE) { holder.linearLayoutSceneItems.setVisibility(View.GONE); } else { holder.linearLayoutSceneItems.setVisibility(View.VISIBLE); } } }); holder.sceneName.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (onItemLongClickListener != null) { onItemLongClickListener.onItemLongClick(v, holder.getAdapterPosition()); } return true; } }); holder.buttonActivateScene.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (SmartphonePreferencesHandler.getVibrateOnButtonPress()) { VibrationHandler.vibrate(fragmentActivity, SmartphonePreferencesHandler.getVibrationDuration()); } new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { ActionHandler.execute(fragmentActivity, scene); return null; } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); // clear previous items holder.linearLayoutSceneItems.removeAllViews(); // hide setup by default holder.linearLayoutSceneItems.setVisibility(View.GONE); // add current setup for (final SceneItem sceneItem : scene.getSceneItems()) { // create a new receiverRow for our current receiver and add it // to our table of all devices of our current room // the row will contain the device name and all buttons LinearLayout receiverRow = new LinearLayout(fragmentActivity); receiverRow.setOrientation(LinearLayout.HORIZONTAL); holder.linearLayoutSceneItems.addView(receiverRow); // setup TextView to display receiver name AppCompatTextView receiverName = new AppCompatTextView(fragmentActivity); receiverName.setText(sceneItem.getReceiver().getName()); receiverName.setTextSize(18); receiverName .setTextColor(ThemeHelper.getThemeAttrColor(fragmentActivity, android.R.attr.textColorPrimary)); receiverName.setGravity(Gravity.CENTER_VERTICAL); receiverRow.addView(receiverName, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1.0f)); TableLayout buttonLayout = new TableLayout(fragmentActivity); receiverRow.addView(buttonLayout, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); int buttonsPerRow; if (sceneItem.getReceiver().getButtons().size() % 3 == 0) { buttonsPerRow = 3; } else { buttonsPerRow = 2; } int i = 0; TableRow buttonRow = null; for (final Button button : sceneItem.getReceiver().getButtons()) { final android.widget.Button buttonView = (android.widget.Button) inflater .inflate(R.layout.simple_button, buttonRow, false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { buttonView.setElevation(0); buttonView.setStateListAnimator(null); } buttonView.setText(button.getName()); buttonView.setEnabled(false); final int accentColor = ThemeHelper.getThemeAttrColor(fragmentActivity, R.attr.colorAccent); final int inactiveColor = ThemeHelper.getThemeAttrColor(fragmentActivity, R.attr.textColorInactive); if (sceneItem.getActiveButton().equals(button)) { buttonView.setTextColor(accentColor); } else { buttonView.setTextColor(inactiveColor); } if (i == 0 || i % buttonsPerRow == 0) { buttonRow = new TableRow(fragmentActivity); buttonRow.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); buttonRow.addView(buttonView); buttonLayout.addView(buttonRow); } else { buttonRow.addView(buttonView); } i++; } } if (holder.getAdapterPosition() == getItemCount() - 1) { holder.footer.setVisibility(View.VISIBLE); } else { holder.footer.setVisibility(View.GONE); } }
From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java
private void addButton(final String senderName, String myEmail, boolean somebodyAnswered, boolean canEdit, TableLayout tableLayout, final ButtonTO button) { TableRow row = new TableRow(this); tableLayout.addView(row);//from w ww . j av a 2 s . c o m row.setLayoutParams(new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT, 1)); // XXX: inconsistent margin between 2 rows final Button buttonView = new Button(this); buttonView.setMinWidth(UIUtils.convertDipToPixels(this, 100)); buttonView.setText(button.caption); buttonView.setTextColor(getResources().getColor(android.R.color.primary_text_dark)); if (somebodyAnswered) buttonView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); else { buttonView.setWidth(mDisplayWidth - UIUtils.convertDipToPixels(this, 12)); } buttonView.setTextSize(19); row.addView(buttonView); final LinearLayout container = (LinearLayout) getLayoutInflater().inflate(R.layout.message_button_detail, null); container.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); boolean buttonSelectedByMe = false; for (MemberStatusTO status : mCurrentMessage.members) { if ((status.status & MessagingPlugin.STATUS_ACKED) == MessagingPlugin.STATUS_ACKED && ((button.id == null && status.button_id == null) || (button.id != null && button.id.equals(status.button_id)))) { getLayoutInflater().inflate(R.layout.avatar, container); ImageView avatar = (ImageView) container.getChildAt(container.getChildCount() - 1); setAvatar(avatar, status.member); if (status.member.equals(myEmail)) buttonSelectedByMe = true; int dp42 = UIUtils.convertDipToPixels(this, 42); int dp2 = UIUtils.convertDipToPixels(this, 1); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) avatar.getLayoutParams(); lp.setMargins(0, dp2, 0, 0); lp.width = dp42; lp.height = dp42; } } row.addView(container); boolean hasAction = button.action != null && !"".equals(button.action); final boolean buttonIsEnabled = canEdit && (mCurrentMessage.form != null || !buttonSelectedByMe || hasAction); buttonView.setEnabled(buttonIsEnabled); int color; if (button.id == null || mCurrentMessage.form != null && Message.POSITIVE.equals(button.id)) { color = buttonIsEnabled ? Message.GREEN_BUTTON_COLOR : Message.GREENGRAY_BUTTON_COLOR; } else if (mCurrentMessage.form != null && Message.NEGATIVE.equals(button.id)) { color = buttonIsEnabled ? Message.RED_BUTTON_COLOR : Message.REDGRAY_BUTTON_COLOR; } else { color = buttonIsEnabled ? Message.BLUE_BUTTON_COLOR : Message.BLUEGRAY_BUTTON_COLOR; } buttonView.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY); buttonView.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { T.UI(); executeButtonClick(button, container, true); } }); final HorizontalScrollView scroller = (HorizontalScrollView) findViewById(R.id.button_scroller); scroller.post(new SafeRunnable() { @Override protected void safeRun() throws Exception { scroller.fullScroll(ScrollView.FOCUS_RIGHT); } }); }
From source file:org.smilec.smile.student.CourseList.java
private void createScoreTable(Vector<Integer> _myscore, String username) { int num_right = countrightquestion(_myscore); int total_question = LAST_SCENE_NUM; TableLayout tl = (TableLayout) findViewById(R.id.tableLayoutSeeR); TextView text1 = (TextView) findViewById(R.id.Header01); text1.setText(getString(R.string.name) + ": " + username); TextView text2 = (TextView) findViewById(R.id.Header11); text2.setText(getString(R.string.t_score) + ":" + num_right + "/" + total_question); for (int i = 0; i < _myscore.size(); i++) { TableRow tr = new TableRow(getApplicationContext()); tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); int number = 0; number = i + 1;/*from ww w . ja v a2 s.c o m*/ int score = _myscore.get(i); Button b = new Button(getApplicationContext()); b.setText("(" + number + ")"); b.setTextSize(resultSize1); // b.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT); params.setMargins(returnPixels(30.0f), 0, returnPixels(30.0f), 0); b.setLayoutParams(params); b.setOnClickListener(new MyButtonListener(number)); /* Add Button to row. */ tr.addView(b); TextView text = new TextView(getApplicationContext()); if (score == 1) { // right text.setText("0"); } else { // wrong text.setText("X"); } text.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); text.setTextColor(Color.BLACK); text.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL); text.setTextSize(resultSize2); tr.addView(text); //tr.setBackgroundResource(R.drawable.sf_gradient_03); tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT)); } return; }
From source file:eu.power_switch.gui.adapter.RoomRecyclerViewAdapter.java
private void updateReceiverViews(final RoomRecyclerViewAdapter.ViewHolder holder, final Room room) { String inflaterString = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater inflater = (LayoutInflater) fragmentActivity.getSystemService(inflaterString); // clear previous items holder.linearLayoutOfReceivers.removeAllViews(); // add items//from w w w . j a va 2s .com for (final Receiver receiver : room.getReceivers()) { // create a new receiverRow for our current receiver and add it to // our table of all devices of our current room // the row will contain the device name and all buttons LinearLayout receiverLayout = (LinearLayout) inflater.inflate(R.layout.list_item_receiver, holder.linearLayoutOfReceivers, false); receiverLayout.setOrientation(LinearLayout.HORIZONTAL); holder.linearLayoutOfReceivers.addView(receiverLayout); // setup TextView to display device name TextView receiverName = (TextView) receiverLayout.findViewById(R.id.txt_name); receiverName.setText(receiver.getName()); receiverName.setTextSize(18); TableLayout buttonLayout = (TableLayout) receiverLayout.findViewById(R.id.buttonLayout); int buttonsPerRow; if (receiver.getButtons().size() % 3 == 0) { buttonsPerRow = 3; } else { buttonsPerRow = 2; } int i = 0; final ArrayList<android.widget.Button> buttonViews = new ArrayList<>(); long lastActivatedButtonId = receiver.getLastActivatedButtonId(); TableRow buttonRow = null; for (final Button button : receiver.getButtons()) { final android.widget.Button buttonView = (android.widget.Button) inflater .inflate(R.layout.simple_button, buttonRow, false); final ColorStateList defaultTextColor = buttonView.getTextColors(); //save original colors buttonViews.add(buttonView); buttonView.setText(button.getName()); final int accentColor = ThemeHelper.getThemeAttrColor(fragmentActivity, R.attr.colorAccent); if (SmartphonePreferencesHandler.getHighlightLastActivatedButton() && lastActivatedButtonId != -1 && button.getId() == lastActivatedButtonId) { buttonView.setTextColor(accentColor); } buttonView.setOnClickListener(new android.widget.Button.OnClickListener() { @Override public void onClick(final View v) { if (SmartphonePreferencesHandler.getVibrateOnButtonPress()) { VibrationHandler.vibrate(fragmentActivity, SmartphonePreferencesHandler.getVibrationDuration()); } new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { // send signal ActionHandler.execute(fragmentActivity, receiver, button); return null; } @Override protected void onPostExecute(Void aVoid) { if (SmartphonePreferencesHandler.getHighlightLastActivatedButton()) { for (android.widget.Button button : buttonViews) { if (button != v) { button.setTextColor(defaultTextColor); } else { button.setTextColor(accentColor); } } } } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); if (i == 0 || i % buttonsPerRow == 0) { buttonRow = new TableRow(fragmentActivity); buttonRow.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)); buttonRow.addView(buttonView); buttonLayout.addView(buttonRow); } else { buttonRow.addView(buttonView); } i++; } receiverLayout.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { ConfigureReceiverDialog configureReceiverDialog = ConfigureReceiverDialog .newInstance(receiver.getId()); configureReceiverDialog.setTargetFragment(recyclerViewFragment, 0); configureReceiverDialog.show(fragmentActivity.getSupportFragmentManager(), null); return true; } }); } }
From source file:com.woofer.activity.personHomeActivity.java
public void showTable() { TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT); layoutParams.gravity = Gravity.LEFT; layoutParams.leftMargin = 30;//from www. jav a 2 s .co m layoutParams.bottomMargin = 10; layoutParams.topMargin = 10; for (int i = 0; i < 30; i++) { TableRow tableRow = new TableRow(this); TextView textView7 = new TextView(this); textView7.setText("" + i); textView7.setTextSize(18); textView7.setTextColor(Color.rgb(0, 0, 0)); textView7.setPadding(15, 0, 15, 0); tableRow.addView(textView7, layoutParams); tableRow.setBackgroundColor(Color.WHITE); final int n = i; tableRow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(personHomeActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show(); } }); mMainLayout.addView(tableRow); TableRow tableRow1 = new TableRow(this); TextView textView1 = new TextView(this); textView1.setText("Test pull down scrollvsfadasdsadsasadsadsadsadsadasdsadasdasdsadsaddasdiew " + i); textView1.setTextSize(16); textView1.setPadding(15, 0, 15, 15); tableRow1.addView(textView1, layoutParams); tableRow1.setBackgroundColor(Color.WHITE); tableRow.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(personHomeActivity.this, "Click item " + n, Toast.LENGTH_SHORT).show(); } }); mMainLayout.addView(tableRow1); // TableRow tableRow2 = new TableRow(this); // //tableRow2.addView(textView2, layoutParams); // ImageView imageView = new ImageView(this); // imageView.setImageResource(R.drawable.icon_reply_t); // imageView.setScaleX((float) a); // imageView.setScaleY((float) a); // imageView.setPadding(0, 0, 0, 0); // // ImageView imageView1 = new ImageView(this); // imageView1.setImageResource(R.drawable.icon_thumb_t); // imageView1.setScaleX((float) a); // imageView1.setScaleY((float) a); // imageView1.setPadding(0, 0, 0, 0); // // // //tableRow2.addView(imageView); // tableRow2.addView(imageView1); // mMainLayout.addView(tableRow2); TableLayout mytable = (TableLayout) findViewById(R.id.degital_textTL); int numberOfRow = 1; int numberOfColumn = 12; int cellDimension = 24; int cellPadding = 200; for (int row = 0; row < numberOfRow; row++) { tableRow = new TableRow(this); //tableRow.setLayoutParams(new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT)); tableRow.setLayoutParams(new TableLayout.LayoutParams( (cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding)); for (int column = 0; column < numberOfColumn; column++) { if (column % 3 == 0) { TextView textView = new TextView(this); textView.setTextSize(20); textView.setText(" "); tableRow.addView(textView); } if (column % 3 == 1) { if (column == 1) { ImageView imageView = new ImageView(this); imageView.setScaleX((float) 0.5); imageView.setScaleY((float) 0.5); imageView.setImageResource(R.drawable.icon_eye_t); tableRow.addView(imageView); } if (column == 4) { ImageView imageView = new ImageView(this); imageView.setScaleX((float) 0.5); imageView.setScaleY((float) 0.5); imageView.setImageResource(R.drawable.icon_thumb_t); tableRow.addView(imageView); } if (column == 7) { ImageView imageView = new ImageView(this); imageView.setScaleX((float) 0.5); imageView.setScaleY((float) 0.5); imageView.setImageResource(R.drawable.icon_reply_t); tableRow.addView(imageView); } if (column == 10) { ImageView imageView = new ImageView(this); imageView.setScaleX((float) 0.5); imageView.setScaleY((float) 0.5); imageView.setImageResource(R.drawable.icon_pencil_t); tableRow.addView(imageView); } } if (column % 3 == 2) { if (column == 2) { TextView textView = new TextView(this); textView.setText("8"); tableRow.addView(textView); } if (column == 5) { TextView textView = new TextView(this); textView.setText("8"); tableRow.addView(textView); } if (column == 8) { TextView textView = new TextView(this); textView.setText("8"); tableRow.addView(textView); } if (column == 11) { TextView textView = new TextView(this); textView.setText("8"); tableRow.addView(textView); } } } mytable.addView(tableRow, new TableLayout.LayoutParams( (cellDimension + 2 * cellPadding) * numberOfColumn, cellDimension + 2 * cellPadding)); //mytable.addView(tableRow,new TableLayout.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.MATCH_PARENT)); } } }
From source file:tinygsn.gui.android.ActivityViewData.java
private void addTableViewModeLatest() { table_view_mode = (TableLayout) findViewById(R.id.table_view_mode); // table_view_mode.setLayoutParams(new // TableLayout.LayoutParams(LayoutParams.FILL_PARENT, // LayoutParams.WRAP_CONTENT)); table_view_mode.removeAllViews();//from www. ja v a 2 s.com TableRow row = new TableRow(this); TextView txt = new TextView(this); txt.setText(" View "); txt.setTextColor(Color.parseColor("#000000")); row.addView(txt); final EditText editText_numLatest = new EditText(this); editText_numLatest.setText("10"); editText_numLatest.setInputType(InputType.TYPE_CLASS_NUMBER); editText_numLatest.requestFocus(); editText_numLatest.setTextColor(Color.parseColor("#000000")); row.addView(editText_numLatest); editText_numLatest.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { try { numLatest = Integer.parseInt(editText_numLatest.getText().toString()); loadLatestData(); } catch (NumberFormatException e) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); alertDialogBuilder.setTitle("Please input a number!"); } } }); txt = new TextView(this); txt.setText(" latest values"); txt.setTextColor(Color.parseColor("#000000")); row.addView(txt); txt = new TextView(this); txt.setText(" "); row.addView(txt); table_view_mode.addView(row); row = new TableRow(this); Button detailBtn = new Button(this); // plotDataBtn.setTextSize(TEXT_SIZE); detailBtn.setText("Detail"); detailBtn.setTextColor(Color.parseColor("#000000")); detailBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Toast.makeText(context, "detailBtn is clicked", // Toast.LENGTH_SHORT).show(); showDialogDetail(); } }); Button plotDataBtn = new Button(this); // plotDataBtn.setTextSize(TEXT_SIZE); plotDataBtn.setText("Plot data"); plotDataBtn.setTextColor(Color.parseColor("#000000")); plotDataBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { viewChart(); } }); TableRow.LayoutParams params = new TableRow.LayoutParams(); // params.addRule(TableRow.LayoutParams.FILL_PARENT); params.span = 2; row.addView(detailBtn, params); row.addView(plotDataBtn, params); row.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT)); table_view_mode.addView(row); }
From source file:tinygsn.gui.android.ActivityViewDataNew.java
private void addTableViewModeLatest() { table_view_mode = (TableLayout) findViewById(R.id.table_view_mode); // table_view_mode.setLayoutParams(new // TableLayout.LayoutParams(LayoutParams.FILL_PARENT, // LayoutParams.WRAP_CONTENT)); table_view_mode.removeAllViews();/* ww w.j av a 2 s . co m*/ TableRow row = new TableRow(this); TextView txt = new TextView(this); txt.setText(" View "); txt.setTextColor(Color.parseColor("#000000")); row.addView(txt); final EditText editText_numLatest = new EditText(this); editText_numLatest.setText("10"); editText_numLatest.setInputType(InputType.TYPE_CLASS_NUMBER); editText_numLatest.requestFocus(); editText_numLatest.setTextColor(Color.parseColor("#000000")); row.addView(editText_numLatest); editText_numLatest.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { try { numLatest = Integer.parseInt(editText_numLatest.getText().toString()); loadLatestData(); } catch (NumberFormatException e) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context); alertDialogBuilder.setTitle("Please input a number!"); } } }); txt = new TextView(this); txt.setText(" latest values"); txt.setTextColor(Color.parseColor("#000000")); row.addView(txt); txt = new TextView(this); txt.setText(" "); row.addView(txt); table_view_mode.addView(row); row = new TableRow(this); Button detailBtn = new Button(this); detailBtn.setText("Detail"); // detailBtn.setBackground(getResources().getDrawable(R.drawable.info)); // detailBtn.setWidth(200); detailBtn.setTextSize(TEXT_SIZE + 2); detailBtn.setTextColor(Color.parseColor("#000000")); detailBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDialogDetail(); } }); Button plotDataBtn = new Button(this); plotDataBtn.setText("Plot data"); plotDataBtn.setTextSize(TEXT_SIZE + 2); plotDataBtn.setTextColor(Color.parseColor("#000000")); // plotDataBtn.setBackground(getResources().getDrawable(R.drawable.chart)); // LinearLayout.LayoutParams params = plotDataBtn.getLayoutParams(); // params.width = 50; // plotDataBtn.setLayoutParams(params); plotDataBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { viewChart(); } }); TableRow.LayoutParams rowParams = new TableRow.LayoutParams(); // params.addRule(TableRow.LayoutParams.FILL_PARENT); rowParams.span = 2; row.addView(detailBtn, rowParams); row.addView(plotDataBtn, rowParams); // detailBtn.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, // LayoutParams.WRAP_CONTENT)); // plotDataBtn.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, // LayoutParams.WRAP_CONTENT)); row.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); table_view_mode.addView(row); }