List of usage examples for android.widget TableRow setLayoutParams
public void setLayoutParams(ViewGroup.LayoutParams params)
From source file:com.example.diplimadoapp.SuperAwesomeCardFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); FrameLayout fl = new FrameLayout(getActivity()); fl.setLayoutParams(params);/*from w w w . j a va 2 s . co m*/ final int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, getResources().getDisplayMetrics()); switch (position) { case 0: LinearLayout ll = new LinearLayout(getActivity()); ll.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ImageView iv = new ImageView(getActivity()); iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 1020)); //iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT)); iv.setMaxHeight(520); iv.setImageResource(R.drawable.contact); ll.addView(iv); TableLayout tl = new TableLayout(getActivity()); tl.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr = new TableRow(getActivity()); tr.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr.setGravity(Gravity.FILL_HORIZONTAL); tr.setPadding(5, 5, 5, 5); List<RssItem> lecturaitems = null; try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); lecturaitems = rssReader.getItems(); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } TextView v1 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v1.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v1.setGravity(Gravity.CENTER); v1.setBackgroundResource(R.drawable.background_card); if (lecturaitems != null) { v1.setText(lecturaitems.get(0).getTitle()); String urlnoticia = lecturaitems.get(0).getLink(); v1.setOnClickListener(new NoticiaDestacadaOnClickListener(urlnoticia)); } else { v1.setText("No Registra nuevas noticias"); } tr.addView(v1); ImageButton ib = new ImageButton(getActivity()); ib.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib.setImageResource(R.drawable.facebook); ib.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.facebook.com")); startActivity(myWebLink); } }); tr.addView(ib); ImageButton ib2 = new ImageButton(getActivity()); ib2.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib2.setImageResource(R.drawable.twitter); ib2.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.twitter.com")); startActivity(myWebLink); } }); tr.addView(ib2); ImageButton ib3 = new ImageButton(getActivity()); ib3.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib3.setImageResource(R.drawable.youtube); ib3.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent myWebLink = new Intent(android.content.Intent.ACTION_VIEW); myWebLink.setData(Uri.parse("http://www.youtube.com")); startActivity(myWebLink); } }); tr.addView(ib3); tl.addView(tr); ll.addView(tl); fl.addView(ll); break; case 1: LinearLayout ll2 = new LinearLayout(getActivity()); ll2.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); ll2.setOrientation(LinearLayout.VERTICAL); TableLayout tl2 = new TableLayout(getActivity()); tl2.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); TableRow tr2 = new TableRow(getActivity()); tr2.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr2.setGravity(Gravity.FILL_HORIZONTAL); tr2.setPadding(5, 5, 5, 5); TextView v0 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v0.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v0.setGravity(Gravity.CENTER); v0.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr2.addView(v0); ImageButton ib20 = new ImageButton(getActivity()); ib20.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib20.setImageResource(R.drawable.pacusticos); ib20.setBackgroundDrawable(null); tr2.addView(ib20); tl2.addView(tr2); TableRow tr3 = new TableRow(getActivity()); tr3.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr3.setGravity(Gravity.FILL_HORIZONTAL); tr3.setPadding(5, 5, 5, 5); TextView v03 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v03.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v03.setGravity(Gravity.CENTER); v03.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr3.addView(v03); ImageButton ib30 = new ImageButton(getActivity()); ib30.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib30.setImageResource(R.drawable.pradionica_lacarta); ib30.setBackgroundDrawable(null); tr3.addView(ib30); tl2.addView(tr3); TableRow tr4 = new TableRow(getActivity()); tr4.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); tr4.setGravity(Gravity.FILL_HORIZONTAL); tr4.setPadding(5, 5, 5, 5); TextView v04 = new TextView(getActivity()); params.setMargins(margin, margin, margin, margin); v04.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); v04.setGravity(Gravity.CENTER); v04.setText("Acusticos Radionoca. Lunes a Viernes 8:00 a.m. - 9:00 a.m."); tr4.addView(v04); tl2.addView(tr4); ImageButton ib40 = new ImageButton(getActivity()); ib40.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1)); ib40.setImageResource(R.drawable.prockeros); ib40.setBackgroundDrawable(null); tr4.addView(ib40); ll2.addView(tl2); /* VideoView videoView = new VideoView(getActivity()); Uri path = Uri.parse("rtmp://cdns840stu0010.multistream.net:80/rtvcRadionicalive/?pass=|radionica|"); videoView.setVideoURI(path); videoView.start(); TableRow tr5 =new TableRow(getActivity()); tr5.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); tr5.setGravity(Gravity.FILL_HORIZONTAL); tr5.setPadding(5,5,5,5); tr5.addView(videoView); ll2.addView(tr5);*/ fl.addView(ll2); break; case 2: ListView lv = new ListView(getActivity()); params.setMargins(margin, margin, margin, margin); lv.setLayoutParams(params); lv.setLayoutParams(params); lv.setBackgroundResource(R.drawable.background_card); try { // Create RSS reader RssReader rssReader = new RssReader( "http://www.senalradionica.gov.co/index.php/home/articulos/itemlist?format=feed"); // Get a ListView from main view //ListView itcItems = (ListView) findViewById(R.id.listMainView); List<RssItem> lecturaitems2 = rssReader.getItems(); // Create a list adapter ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(getActivity(), android.R.layout.simple_list_item_1, lecturaitems2); // Set list adapter for the ListView lv.setAdapter(adapter); // Set list view item click listener lv.setOnItemClickListener(new ListListener(lecturaitems2, getActivity())); } catch (Exception e) { Log.e("Diplomado App Reader", e.getMessage()); } fl.addView(lv); break; } return fl; }
From source file:com.example.parkhere.seeker.SeekerProfileVehicleFragment.java
public void addVehicle(final Vehicle vehicle) { 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.ADD_VEHICLE_OPERATION); request.setUser(user);/*from w w w .j av a2 s . c o m*/ request.setVehicle(vehicle); 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)) { 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(vehicle.getMake()); v_make.setLayoutParams(new TableRow.LayoutParams(300, 150)); tr.addView(v_make); TextView v_model = new TextView(myContext); v_model.setText(vehicle.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(vehicle.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)); Vehicle[] arr = new Vehicle[vehicles.length + 1]; for (int i = 0; i < vehicles.length; i++) { arr[i] = vehicles[i]; } arr[vehicles.length] = vehicle; vehicles = arr; } Snackbar.make(rootView, resp.getMessage(), Snackbar.LENGTH_LONG).show(); } @Override public void onFailure(Call<ServerResponse> call, Throwable t) { Snackbar.make(rootView, t.getLocalizedMessage(), Snackbar.LENGTH_LONG).show(); } }); }
From source file:com.example.hllut.app.Deprecated.MainActivity.java
/** * fill the "liters of petrol" textView, as well as drawing the petrol barrels *///from w w w . j a v a 2 s . co m private void drawPetrol() { //TODO use the bundle float litersOfPetrol = (TOTAL_CO2 / CO2_PER_LITRE_PETROL); TextView tv = (TextView) findViewById(R.id.litersTextView); tv.setText("Burning " + String.format("%.2f", litersOfPetrol) + " liters of petrol"); TableLayout layout = (TableLayout) findViewById(R.id.petrolContainer); TableRow newRow = new TableRow(this); LinearLayout linLay = new LinearLayout(this); linLay.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f)); newRow.setLayoutParams( new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); newRow.setPadding(10, 10, 10, 10); for (int i = 1; i < (int) litersOfPetrol + 1; i++) { // // TODO: To many images fuck up formatting // Create images ImageView im = new ImageView(this); im.setImageResource(R.drawable.oil_barrel); im.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); //barrells per row = 7 if (i % 7 == 0) { // if you have gone 7 laps // print what you have linLay.addView(im); newRow.addView(linLay, new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); layout.addView(newRow, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT)); newRow = new TableRow(this); linLay = new LinearLayout(this); linLay.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f)); newRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); newRow.setPadding(10, 10, 10, 10); } else { linLay.addView(im); } } newRow.addView(linLay, new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); layout.addView(newRow, new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT)); }
From source file:com.example.hllut.app.Deprecated.MainActivity.java
/** * Fills "amount of planets" textView as well as drawing the planets *//*from w w w . j av a 2 s.c om*/ private void drawPlanets() { //TODO use the bundle int numberOfPlanets = (int) (TOTAL_CO2 / MAX_CO2_PER_PERSON); TextView need = (TextView) findViewById(R.id.planetsTextView); need.setText("We would need " + numberOfPlanets + " planets"); TableLayout layout = (TableLayout) findViewById(R.id.planetContainer); TableRow tbr = new TableRow(this); LinearLayout linearLayout = new LinearLayout(this); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f)); //TODO tbr.setLayoutParams( new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT)); tbr.setPadding(10, 10, 10, 10); for (int i = 1; i < numberOfPlanets + 1; i++) { // TODO: Too many planets fuck up formatting // Create images ImageView im = new ImageView(this); im.setImageResource(R.drawable.earth); im.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f)); im.setPadding(10, 10, 10, 10); //planets per row = 5 if (i % 5 == 0) { // if you have gone 5 laps // print what you have linearLayout.addView(im); tbr.addView(linearLayout, new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, 1f)); layout.addView(tbr, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT)); tbr = new TableRow(this); linearLayout = new LinearLayout(this); linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1f)); tbr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT)); tbr.setPadding(10, 10, 10, 10); } else { linearLayout.addView(im); } } tbr.addView(linearLayout, new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1f)); // layout.addView(tbr, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.MATCH_PARENT)); }
From source file:com.example.parkhere.seeker.SeekerProfileVehicleFragment.java
public void getCurrInfo() { tag = 1;// ww w . j a v a2 s . co 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:com.adarshahd.indianrailinfo.donate.PNRStat.java
private void createTableLayoutTrnDtls() { 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 . j a v a 2 s. com*/ mFrameLayout.addView(mTextViewPNRSts); 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); return; } List<String> trainList; if (mTrainDetails == null || mTrainDetails.getPNR() != mPNRNumber) { Elements eleTrain = Jsoup.parse(mPageResult).select("table tr tr td:containsOwn(Train Number)"); Iterator iteTrain = null; try { iteTrain = eleTrain.first().parent().parent().parent().getElementsByTag("tr").iterator(); } catch (Exception e) { Log.i("PNRStat", mPageResult); return; } trainList = new ArrayList<String>(); Element tmp; //Get the third row for train details iteTrain.next(); iteTrain.next(); if (iteTrain.hasNext()) { tmp = (Element) iteTrain.next(); trainList.add(tmp.select("td").get(0).text()); trainList.add(tmp.select("td").get(1).text()); trainList.add(tmp.select("td").get(2).text()); trainList.add(tmp.select("td").get(5).text()); trainList.add(tmp.select("td").get(6).text()); trainList.add(tmp.select("td").get(7).text()); } mTrainDetails = new TrainDetails(trainList, mPNRNumber); } else { trainList = mTrainDetails.getTrainDetails(); } mTableLayoutTrn = new TableLayout(mActivity); mTableLayoutTrn.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); TableRow row = new TableRow(mActivity); mStrTrainDetails = new String(); row.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); for (String list : trainList) { TextView tv = new TextView(mActivity); tv.setText(list); tv.setPadding(10, 10, 10, 10); tv.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Small); row.addView(tv); mStrTrainDetails += list + " "; } row.setBackgroundResource(R.drawable.card_background); row.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); mTableLayoutTrn.addView(row); }
From source file:org.mythdroid.activities.Guide.java
/** * Generate a TableRow from the provided Channel * @param ch Channel to generate a row for * @return populated TableRow representing the channel *///from w w w . ja v a 2 s. c o m @SuppressLint("DefaultLocale") private TableRow getRowFromChannel(Channel ch) { final TableRow row = new TableRow(this); row.setLayoutParams(rowLayout); TextView tv = new TextView(this); tv.setBackgroundColor(0xffe0e0f0); tv.setTextColor(0xff202020); tv.setPadding(4, 4, 4, 4); tv.setMaxLines(2); tv.setTag(ch.ID); tv.setText(ch.num + " " + ch.callSign); //$NON-NLS-1$ tv.setOnClickListener(chanClickListener); tv.setOnLongClickListener(chanLongClickListener); tv.setLayoutParams(chanLayout); row.addView(tv); LayoutParams layout = null; Program[] progs = ch.programs.toArray(new Program[ch.programs.size()]); int numprogs = progs.length; for (int i = 0; i < numprogs; i++) { if (progs[i].StartTime.equals(later)) continue; tv = new TextView(this); layout = new LayoutParams(this, null); layout.topMargin = layout.bottomMargin = layout.leftMargin = layout.rightMargin = 1; layout.height = rowHeight; String cat = catPat.matcher(progs[i].Category.toLowerCase()).replaceAll(""); //$NON-NLS-1$ try { tv.setBackgroundColor(Category.valueOf(cat).color()); } catch (IllegalArgumentException e) { tv.setBackgroundColor(Category.unknown.color()); } tv.setTextColor(0xfff0f0f0); tv.setPadding(4, 4, 4, 4); tv.setMaxLines(2); tv.setText(progs[i].Title); setStatusDrawable(tv, progs[i]); int width = setLayoutParams(layout, progs[i]) * colWidth; if (width < 1) continue; tv.setWidth(width); tv.setLayoutParams(layout); tv.setTag(progs[i]); tv.setOnClickListener(progClickListener); row.addView(tv); } return row; }
From source file:org.mythdroid.activities.Guide.java
/** * Get a spacer row//w w w .ja va2 s. c o m * @return a spacer TableRow */ private TableRow getSpacer() { final TableRow row = new TableRow(this, null); LayoutParams params = new LayoutParams(); params.height = 1; row.setLayoutParams(params); View view = new View(this, null); params = new LayoutParams(); params.height = 1; params.width = chanWidth; params.column = 0; params.span = 1; view.setLayoutParams(params); row.addView(view); for (int i = 1; i < times.length; i++) { view = new View(this, null); view.setLayoutParams(spacerLayout); row.addView(view); } return row; }
From source file:ru.adios.budgeter.widgets.DataTableLayout.java
private TableRow constructRow(Context context, float weightSum) { final TableRow row = new TableRow(context); row.setId(ElementsIdProvider.getNextId()); row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); row.setWeightSum(weightSum);// ww w . j a va 2s .co m return row; }
From source file:ru.adios.budgeter.widgets.DataTableLayout.java
/** * Requires tableName to be checked, i.e. isPresent() == true . *//*from ww w .j a v a2s . co m*/ private void addTitleRowWithSeparator(Context context, float layoutWeightSum, float titleViewWeight) { final TableRow tableNameRow = new TableRow(context); tableNameRow.setId(ElementsIdProvider.getNextId()); tableNameRow.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); tableNameRow.setWeightSum(1f); titleView = Optional .of(getCenteredRowText(context, tableName.get(), layoutWeightSum, true, titleViewWeight)); tableNameRow.addView(titleView.get()); addView(tableNameRow, 1); addView(constructRowSeparator(1), 2); headerOffset += 2; }