List of usage examples for android.widget TableRow TableRow
public TableRow(Context context)
Creates a new TableRow for the given context.
From source file:com.example.parkhere.seeker.SeekerProfileVehicleFragment.java
public void getCurrInfo() { tag = 1;/* ww w. ja v a2s. c o m*/ Retrofit retrofit = new Retrofit.Builder().baseUrl(Constants.BASE_URL) .addConverterFactory(GsonConverterFactory.create()).build(); RequestInterface requestInterface = retrofit.create(RequestInterface.class); ServerRequest request = new ServerRequest(); request.setOperation(Constants.GET_SEEKER_PROFILE_OPERATION); request.setUser(user); Call<ServerResponse> response = requestInterface.operation(request); response.enqueue(new Callback<ServerResponse>() { @Override public void onResponse(Call<ServerResponse> call, retrofit2.Response<ServerResponse> response) { ServerResponse resp = response.body(); if (resp.getResult().equals(Constants.SUCCESS)) { vehicles = resp.getVehicles(); TableRow tr_head = new TableRow(myContext); tr_head.setBackgroundColor(Color.GRAY); tr_head.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); TextView make = new TextView(myContext); make.setText("MAKE"); make.setTextColor(Color.WHITE); make.setPadding(5, 5, 5, 5); tr_head.addView(make); TextView model = new TextView(myContext); model.setText("MODEL"); model.setTextColor(Color.WHITE); model.setPadding(5, 5, 5, 5); tr_head.addView(model); final TextView license = new TextView(myContext); license.setText("LICENSE PLATE"); license.setTextColor(Color.WHITE); license.setPadding(5, 5, 5, 5); tr_head.addView(license); tl.addView(tr_head, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT)); for (int i = 0; i < vehicles.length; i++) { if (vehicles[i].getDeletedWithHistory() == 1) { continue; } TableRow tr = new TableRow(myContext); tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); tr.setTag(tag); tag++; tr.setClickable(true); tr.setOnClickListener(clickListener); TextView v_make = new TextView(myContext); v_make.setText(vehicles[i].getMake()); v_make.setLayoutParams(new TableRow.LayoutParams(300, 150)); tr.addView(v_make); TextView v_model = new TextView(myContext); v_model.setText(vehicles[i].getModel()); v_model.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); tr.addView(v_model); TextView v_license = new TextView(myContext); v_license.setText(vehicles[i].getLicensePlate()); v_license.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); tr.addView(v_license); tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT, TableLayout.LayoutParams.WRAP_CONTENT)); } } } @Override public void onFailure(Call<ServerResponse> call, Throwable t) { Snackbar.make(rootView, t.getLocalizedMessage(), Snackbar.LENGTH_LONG).show(); } }); }
From source file:nl.openkvk.MainActivity.java
public void searchInKvK(View view) { TableLayout tl = (TableLayout) findViewById(R.id.tableOuter); tl.removeAllViews();//from www. j av a 2 s.c o m EditText _naam = (EditText) findViewById(R.id.inpNaam); EditText _straat = (EditText) findViewById(R.id.inpStraat); EditText _postcode = (EditText) findViewById(R.id.inpPostcode); EditText _plaats = (EditText) findViewById(R.id.inpPlaats); EditText _hdlNaam = (EditText) findViewById(R.id.inpHandelsNaam); String naam = _naam.getText().toString().trim(); String hdlNaam = _hdlNaam.getText().toString().trim(); String straat = _straat.getText().toString().trim(); String postcode = _postcode.getText().toString().trim().toUpperCase(); if (postcode.indexOf(' ') > 0) { postcode = postcode.replace(" ", ""); } String plaats = _plaats.getText().toString().trim(); _naam.setText(naam); _hdlNaam.setText(hdlNaam); _straat.setText(straat); _postcode.setText(postcode); _plaats.setText(plaats); String sql = null; if (naam.length() > 0) { try { Integer kvk = Integer.valueOf(naam); sql = "/json/select * from kvk where kvks=" + kvk; } catch (Exception ignore) { sql = "/json/select * from kvk where bedrijfsnaam ilike '" + naam + "%'"; } if (straat.length() > 0) { sql += " and adres ilike '" + straat + "%'"; } if (plaats.length() > 0) { sql += " and plaats ilike '" + plaats + "%'"; } if (postcode.length() > 0) { sql += " and postcode ilike '" + postcode + "%'"; } sql += " LIMIT 1000;"; } else if (hdlNaam.length() > 0) { sql = "/json/select * from kvk,kvk_handelsnamen where kvk.kvks=kvk_handelsnamen.kvks and handelsnaam ilike '" + hdlNaam + "%'"; sql += " LIMIT 1000;"; } else if (straat.length() > 0 && (plaats.length() > 0 || postcode.length() > 0)) { sql = "/json/select * from kvk where adres ilike '" + straat + "%'"; if (plaats.length() > 0) { sql += " and plaats ilike '" + plaats + "%'"; } if (postcode.length() > 0) { sql += " and postcode ilike '" + postcode + "%'"; } sql += " LIMIT 1000;"; } else if (postcode.length() == 6) { sql = "/json/select * from kvk where postcode='" + postcode + "'"; sql += " LIMIT 1000;"; } if (sql != null) { TextView tv = new TextView(this); tv.setText("Even geduld AUB..."); TableRow tr = new TableRow(this); tr.addView(tv); tl.addView(tr); new Caller(handler, handler.holder, sql, 2).start(); } else { { TextView tv = new TextView(this); tv.setText("Ongeldige invoer."); TableRow tr = new TableRow(this); tr.addView(tv); tl.addView(tr); } { TextView tv = new TextView(this); tv.setText("Geef een (gedeelte van) een bedrijfsnaam in. Of geef het KvK nummer."); tv.setSingleLine(false); TableRow tr = new TableRow(this); tr.addView(tv); tl.addView(tr); } { TextView tv = new TextView(this); tv.setText("Geef eventueel ook (het begin van) een straat, postcode en/of plaatsnaam in."); tv.setSingleLine(false); TableRow tr = new TableRow(this); tr.addView(tv); tl.addView(tr); } { TextView tv = new TextView(this); tv.setText("Of geef een straat (mag met huisnummer) en een plaats en/of een postcode in."); tv.setSingleLine(false); TableRow tr = new TableRow(this); tr.addView(tv); tl.addView(tr); } { TextView tv = new TextView(this); tv.setText("Of geef alleen een volledige postcode in."); tv.setSingleLine(false); TableRow tr = new TableRow(this); tr.addView(tv); tl.addView(tr); } } }
From source file:no.barentswatch.fiskinfo.MapActivity.java
public View getMapLayerCheckBoxRow(Context context, String mapLayerName) { TableRow tr = new TableRow(context); View v = LayoutInflater.from(context).inflate(R.layout.map_layer_check_box_row, tr, false); final int tablePadding = 5; TextView textView = (TextView) v.findViewById(R.id.map_layer_row_text_view); textView.setText(mapLayerName);/*from ww w .ja v a 2s.c o m*/ v.setPadding(tablePadding, tablePadding, tablePadding, tablePadding); return v; }
From source file:com.ninetwozero.battlelog.fragments.PlatoonStatsFragment.java
public void generateTableRows(TableLayout parent, List<PlatoonStatsItem> stats, boolean isTime) { // Make sure the cache is null, as well as the table being cleared cacheTableRow = null;//from w w w . j a va2 s. c o m parent.removeAllViews(); // Loop over them, *one* by *one* if (stats != null) { // The number of items (-1) as the overall is a field that shouldn't // be counted int numItems = stats.size() - 1; int avg; // Iterate over the stats for (int i = 0, max = (numItems + 1); i < max; i++) { // Set the average avg = (i == 0) ? (stats.get(i).getAvg() / numItems) : stats.get(i).getAvg(); // Is it null? cacheView = (RelativeLayout) layoutInflater.inflate(R.layout.grid_item_platoon_stats, null); // Add the new TableRow if (cacheTableRow == null || (i % 3) == 0) { parent.addView(cacheTableRow = new TableRow(context)); cacheTableRow.setLayoutParams( new TableRow.LayoutParams( TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT ) ); } // Add the *layout* into the TableRow cacheTableRow.addView(cacheView); // Set the label ((TextView) cacheView.findViewById(R.id.text_label)) .setText(stats.get(i).getLabel().toUpperCase() + ""); // If (i == 0) => Overall if (isTime) { ((TextView) cacheView.findViewById(R.id.text_average)).setText(PublicUtils.timeToLiteral(avg)); ((TextView) cacheView.findViewById(R.id.text_max)) .setText(PublicUtils.timeToLiteral(stats.get(i).getMax())); ((TextView) cacheView.findViewById(R.id.text_mid)) .setText(PublicUtils.timeToLiteral(stats.get(i).getMid())); ((TextView) cacheView.findViewById(R.id.text_min)) .setText(PublicUtils.timeToLiteral(stats.get(i).getMin())); } else { ((TextView) cacheView.findViewById(R.id.text_average)).setText(avg + ""); ((TextView) cacheView.findViewById(R.id.text_max)).setText(stats.get(i).getMax() + ""); ((TextView) cacheView.findViewById(R.id.text_mid)).setText(stats.get(i).getMid() + ""); ((TextView) cacheView.findViewById(R.id.text_min)).setText(stats.get(i).getMin() + ""); } } } else { // Create a new row parent.addView(cacheTableRow = new TableRow(context)); cacheTableRow.setLayoutParams( new TableRow.LayoutParams( TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT ) ); // Add a TextView & set it up cacheTableRow.addView(cacheView = new TextView(context)); ((TextView) cacheView).setText(R.string.info_stats_not_found); ((TextView) cacheView).setGravity(Gravity.CENTER); } }
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 .c o 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); }
From source file:org.comixwall.pffw.InfoIfs.java
@Override public void onBindViewHolder(IfViewHolder holder, int position) { If ifInfo = ifsList.get(position);/* www . j a v a2 s . c o m*/ holder.name.setText(ifInfo.name); holder.number.setText(ifInfo.num); holder.statesRules.setText(String.format(holder.statesRules.getResources().getString(R.string.states_rules), ifInfo.states, ifInfo.rules)); holder.cleared .setText(String.format(holder.cleared.getResources().getString(R.string.cleared), ifInfo.cleared)); holder.table.removeAllViews(); TableRow row = (TableRow) LayoutInflater.from(holder.table.getContext()).inflate(R.layout.ifs_table_row, new TableRow(holder.table.getContext()), true); ((TextView) row.findViewById(R.id.rowHeader)).setText(R.string.in4); ((TextView) row.findViewById(R.id.passPackets)).setText(ifInfo.in4PassPackets); ((TextView) row.findViewById(R.id.passBytes)).setText(ifInfo.in4PassBytes); ((TextView) row.findViewById(R.id.blockPackets)).setText(ifInfo.in4BlockPackets); ((TextView) row.findViewById(R.id.blockBytes)).setText(ifInfo.in4BlockBytes); holder.table.addView(row); row = (TableRow) LayoutInflater.from(holder.table.getContext()).inflate(R.layout.ifs_table_row, new TableRow(holder.table.getContext()), true); ((TextView) row.findViewById(R.id.rowHeader)).setText(R.string.out4); ((TextView) row.findViewById(R.id.passPackets)).setText(ifInfo.out4PassPackets); ((TextView) row.findViewById(R.id.passBytes)).setText(ifInfo.out4PassBytes); ((TextView) row.findViewById(R.id.blockPackets)).setText(ifInfo.out4BlockPackets); ((TextView) row.findViewById(R.id.blockBytes)).setText(ifInfo.out4BlockBytes); holder.table.addView(row); row = (TableRow) LayoutInflater.from(holder.table.getContext()).inflate(R.layout.ifs_table_row, new TableRow(holder.table.getContext()), true); ((TextView) row.findViewById(R.id.rowHeader)).setText(R.string.in6); ((TextView) row.findViewById(R.id.passPackets)).setText(ifInfo.in6PassPackets); ((TextView) row.findViewById(R.id.passBytes)).setText(ifInfo.in6PassBytes); ((TextView) row.findViewById(R.id.blockPackets)).setText(ifInfo.in6BlockPackets); ((TextView) row.findViewById(R.id.blockBytes)).setText(ifInfo.in6BlockBytes); holder.table.addView(row); row = (TableRow) LayoutInflater.from(holder.table.getContext()).inflate(R.layout.ifs_table_row, new TableRow(holder.table.getContext()), true); ((TextView) row.findViewById(R.id.rowHeader)).setText(R.string.out6); ((TextView) row.findViewById(R.id.passPackets)).setText(ifInfo.out6PassPackets); ((TextView) row.findViewById(R.id.passBytes)).setText(ifInfo.out6PassBytes); ((TextView) row.findViewById(R.id.blockPackets)).setText(ifInfo.out6BlockPackets); ((TextView) row.findViewById(R.id.blockBytes)).setText(ifInfo.out6BlockBytes); holder.table.addView(row); }
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 v a2s. c om 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.github.vseguip.sweet.contacts.SweetConflictResolveActivity.java
/** * @param fieldTable/* w w w . j a va2s . c o m*/ * @param nameOfField * @param field */ private void addConflictRow(TableLayout fieldTable, final String nameOfField, final String fieldLocal, final String fieldRemote) { if (mCurrentLocal == null || mCurrentSugar == null) return; // String fieldLocal = mCurrentLocal.get(nameOfField); // String fieldRemote = mCurrentSugar.get(nameOfField); TableRow row = new TableRow(this); final Spinner sourceSelect = new Spinner(this); sourceSelect.setBackgroundResource(R.drawable.black_underline); ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, this.getResources().getStringArray(R.array.conflict_sources)); spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sourceSelect.setAdapter(spinnerArrayAdapter); // Open the spinner when pressing any of the text fields OnClickListener spinnerOpener = new OnClickListener() { @Override public void onClick(View v) { sourceSelect.performClick(); } }; row.addView(sourceSelect); fieldTable.addView(row); row = new TableRow(this); TextView fieldName = new TextView(this); int stringId = this.getResources().getIdentifier(nameOfField, "string", this.getPackageName()); fieldName.setText(this.getString(stringId)); fieldName.setTextSize(16); fieldName.setPadding(fieldName.getPaddingLeft(), fieldName.getPaddingTop(), fieldName.getPaddingRight() + 10, fieldName.getPaddingBottom()); fieldName.setOnClickListener(spinnerOpener); row.addView(fieldName); final TextView fieldValueLocal = new TextView(this); fieldValueLocal.setText(fieldLocal); fieldValueLocal.setTextSize(16); row.addView(fieldValueLocal); fieldValueLocal.setOnClickListener(spinnerOpener); fieldTable.addView(row); row = new TableRow(this); row.addView(new TextView(this));// add dummy control final TextView fieldValueRemote = new TextView(this); fieldValueRemote.setText(fieldRemote); fieldValueRemote.setTextSize(16); fieldValueRemote.setOnClickListener(spinnerOpener); row.addView(fieldValueRemote); sourceSelect.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (position == 0) { fieldValueLocal.setTextAppearance(SweetConflictResolveActivity.this, R.style.textSelected); fieldValueRemote.setTextAppearance(SweetConflictResolveActivity.this, R.style.textUnselected); resolvedContacts[mPosResolved].set(nameOfField, fieldLocal); } else { fieldValueLocal.setTextAppearance(SweetConflictResolveActivity.this, R.style.textUnselected); fieldValueRemote.setTextAppearance(SweetConflictResolveActivity.this, R.style.textSelected); resolvedContacts[mPosResolved].set(nameOfField, fieldRemote); } } @Override public void onNothingSelected(AdapterView<?> view) { } }); row.setPadding(row.getLeft(), row.getTop() + 5, row.getRight(), row.getBottom() + 10); // Restore appropiate selections according to resolved contact if (resolvedContacts[mPosResolved].get(nameOfField).equals(fieldLocal)) { sourceSelect.setSelection(0); } else { sourceSelect.setSelection(1); } fieldTable.addView(row); }
From source file:com.QuarkLabs.BTCeClient.fragments.HomeFragment.java
/** * Refreshes funds table with fetched data * * @param response JSONObject with funds data *//*from ww w .j a v a 2 s . co m*/ private void refreshFunds(JSONObject response) { try { if (response == null) { Toast.makeText(getActivity(), getResources().getString(R.string.GeneralErrorText), Toast.LENGTH_LONG).show(); return; } String notificationText; if (response.getInt("success") == 1) { View.OnClickListener fillAmount = new View.OnClickListener() { @Override public void onClick(View v) { ScrollView scrollView = (ScrollView) getView(); if (scrollView != null) { EditText tradeAmount = (EditText) scrollView.findViewById(R.id.TradeAmount); tradeAmount.setText(((TextView) v).getText()); scrollView.smoothScrollTo(0, scrollView.findViewById(R.id.tradingSection).getBottom()); } } }; notificationText = getResources().getString(R.string.FundsInfoUpdatedtext); TableLayout fundsContainer = (TableLayout) getView().findViewById(R.id.FundsContainer); fundsContainer.removeAllViews(); JSONObject funds = response.getJSONObject("return").getJSONObject("funds"); JSONArray fundsNames = response.getJSONObject("return").getJSONObject("funds").names(); List<String> arrayList = new ArrayList<>(); for (int i = 0; i < fundsNames.length(); i++) { arrayList.add(fundsNames.getString(i)); } Collections.sort(arrayList); TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, 1); for (String anArrayList : arrayList) { TableRow row = new TableRow(getActivity()); TextView currency = new TextView(getActivity()); TextView amount = new TextView(getActivity()); currency.setText(anArrayList.toUpperCase(Locale.US)); amount.setText(funds.getString(anArrayList)); currency.setLayoutParams(layoutParams); currency.setTypeface(Typeface.DEFAULT, Typeface.BOLD); currency.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16); currency.setGravity(Gravity.CENTER); amount.setLayoutParams(layoutParams); amount.setGravity(Gravity.CENTER); amount.setOnClickListener(fillAmount); row.addView(currency); row.addView(amount); fundsContainer.addView(row); } } else { notificationText = response.getString("error"); } mCallback.makeNotification(ConstantHolder.ACCOUNT_INFO_NOTIF_ID, notificationText); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.adamkruger.myipaddressinfo.NetworkInfoFragment.java
private TableRow makeTableRow(TextView label, TextView value) { TableRow tableRow = new TableRow(getActivity()); tableRow.setLayoutParams(//w w w.ja v a2s. c om new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT)); tableRow.addView(label); if (value != null) { tableRow.addView(value); } return tableRow; }