List of usage examples for android.widget TableRow TableRow
public TableRow(Context context)
Creates a new TableRow for the given context.
From source file:edu.cwru.apo.Directory.java
private void loadTable() { ProgressDialog progDialog = ProgressDialog.show(this, "Loading", "Please Wait", false); userTable.removeAllViews();/*from w ww . j a v a 2 s . c om*/ Cursor results = database.query("phoneDB", new String[] { "first", "last", "_id", "phone" }, null, null, null, null, "first"); String rowText = ""; TableRow row; TextView text; if (!results.moveToFirst()) return; while (!results.isAfterLast()) { String phoneNumber = removeNonDigits(results.getString(3)); if (!(phoneNumber == null || phoneNumber.trim().equals("") || phoneNumber.trim().equals("null"))) { rowText = results.getString(0) + " " + results.getString(1) + " [" + results.getString(2) + "]"; row = new TableRow(this); text = new TextView(this); row.setPadding(0, 5, 0, 5); text.setClickable(true); text.setOnClickListener(this); //text.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); text.setText(rowText); userTable.addView(row); row.addView(text); } results.moveToNext(); } progDialog.cancel(); }
From source file:hongik.android.project.best.StoreActivity.java
public void drawPage() throws Exception { String query = "func=storereview" + "&license=" + license; DBConnector conn = new DBConnector(query); conn.start();/*from www . ja va 2 s . c om*/ conn.join(); JSONObject jsonResult = conn.getResult(); boolean result = jsonResult.getBoolean("result"); if (!result) return; final JSONObject store = jsonResult.getJSONArray("store").getJSONObject(0); JSONArray menu = null; if (!jsonResult.isNull("menu")) menu = jsonResult.getJSONArray("menu"); JSONArray review = null; if (!jsonResult.isNull("review")) review = jsonResult.getJSONArray("review"); //Draw Store Information Lat = Double.parseDouble(store.getString("LAT")); Lng = Double.parseDouble(store.getString("LNG")); sname = store.getString("SNAME"); ((TextViewPlus) findViewById(R.id.store_storename)).setText(sname); ((TextViewPlus) findViewById(R.id.store_address)).setText(store.getString("ADDR")); ImageLoader imgLoader = new ImageLoader(store.getString("IMG")); imgLoader.start(); try { imgLoader.join(); Bitmap storeImg = imgLoader.getBitmap(); ((ImageView) findViewById(R.id.store_image)).setImageBitmap(storeImg); } catch (InterruptedException e) { Toast.makeText(this, "Can not bring " + license + "store's image", Toast.LENGTH_SHORT).show(); Log.e("StoreInfo", "Can not bring " + license + "store's image"); } //Draw Menu Table if (menu != null) { TableRow motive = (TableRow) menuTable.getChildAt(1); for (int i = 0; i < menu.length(); i++) { JSONObject json = menu.getJSONObject(i); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[3]; final String[] elements = new String[2]; elements[0] = json.getString("ITEM#"); elements[1] = json.getString("PRICE"); imgLoader = new ImageLoader(json.getString("IMG")); imgLoader.start(); imgLoader.join(); ImageView img = new ImageView(this); Bitmap bitmap = imgLoader.getBitmap(); img.setImageBitmap(bitmap); img.setLayoutParams(motive.getChildAt(0).getLayoutParams()); img.setScaleType(ImageView.ScaleType.FIT_XY); img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent storeIntent = new Intent(originActivity, MenuActivity.class); storeIntent.putExtra("LICENSE", license); storeIntent.putExtra("MENU", elements[0]); startActivity(storeIntent); } }); tbRow.addView(img); for (int j = 0; j < 2; j++) { tbCols[j] = new TextViewPlus(this); tbCols[j].setText(elements[j]); tbCols[j].setLayoutParams(motive.getChildAt(j + 1).getLayoutParams()); tbCols[j].setGravity(Gravity.CENTER); tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(), "InterparkGothicBold.ttf")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent storeIntent = new Intent(originActivity, MenuActivity.class); storeIntent.putExtra("LICENSE", license); storeIntent.putExtra("MENU", elements[0]); startActivity(storeIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } menuTable.addView(tbRow); } } menuTable.removeViewAt(1); //Draw Review Table if (review != null) { TableRow motive = (TableRow) reviewTable.getChildAt(1); int rowCnt = 5; if (review.length() < 5) rowCnt = review.length(); for (int i = 0; i < rowCnt; i++) { JSONObject json = review.getJSONObject(i); final String[] elements = new String[4]; elements[0] = Double.parseDouble(json.getString("GRADE")) + ""; elements[1] = json.getString("NOTE"); elements[2] = json.getString("CID#"); elements[3] = json.getString("DAY"); TableRow tbRow = new TableRow(this); TextViewPlus[] tbCols = new TextViewPlus[4]; if (elements[1].length() > 14) elements[1] = elements[1].substring(0, 14) + "..."; for (int j = 0; j < 4; j++) { tbCols[j] = new TextViewPlus(this); tbCols[j].setText(elements[j]); tbCols[j].setLayoutParams(motive.getChildAt(j).getLayoutParams()); tbCols[j].setGravity(Gravity.CENTER); tbCols[j].setTypeface(Typeface.createFromAsset(tbCols[j].getContext().getAssets(), "InterparkGothicBold.ttf")); tbCols[j].setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent reviewIntent = new Intent(originActivity, ReviewDetailActivity.class); reviewIntent.putExtra("ACCESS", "STORE"); reviewIntent.putExtra("CID", elements[2]); reviewIntent.putExtra("LICENSE", license); Log.i("StoreReview", "StartActivity"); startActivity(reviewIntent); } }); Log.i("StoreMenu", "COL" + j + ":" + elements[j]); tbRow.addView(tbCols[j]); } reviewTable.addView(tbRow); } } reviewTable.removeViewAt(1); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.store_map); mapFragment.getMapAsync(this); }
From source file:nl.openkvk.MainActivity.java
private void globalSearchResults(Object obj) { {/*www .j a v a 2 s . co m*/ Log.d("Result", obj.toString()); TableLayout tl = (TableLayout) findViewById(R.id.tableOuter); tl.removeAllViews(); JSONResult res = new JSONResult((JSONObject) ((JSONObject) ((JSONArray) obj).get(0)).get("RESULT")); if (res.size() < 1) { TextView v1 = new TextView(this); v1.setText("Niets gevonden voor deze zoekvraag."); TableRow tr = new TableRow(this); tr.addView(v1); tl.addView(tr); } for (int r = 0; r < res.size(); r++) { { TableRow tr = new TableRow(this); TextView v1 = new TextView(this); tr.addView(v1); tl.addView(tr); } print(tl, "Naam: ", res.getValue(r, "bedrijfsnaam")); print(tl, "KvK: ", res.getValue(r, "kvks")); print(tl, "VestNr: ", res.getValue(r, "vestiging")); print(tl, "Type: ", res.getValue(r, "type")); print(tl, "Rechtsvorm: ", res.getValue(r, "rechtsvorm")); print(tl, "Status: ", res.getValue(r, "status")); print(tl, "Website: ", res.getValue(r, "website")); print(tl, "ANBI: ", res.getValue(r, "anbi")); print(tl, "Adres: ", res.getValue(r, "adres")); String po = res.getValue(r, "postcode"); String pl = res.getValue(r, "plaats"); if (po != null || pl != null) { if (po == null) { print(tl, "", pl); } else if (pl == null) { print(tl, "", po); } else { print(tl, "", po + " " + pl); } } { TableRow tr = new TableRow(this); if (res.getValue(r, "kvk") != null && res.getValue(r, "kvks") != null) { Button but = new Button(this); but.setText("Details"); but.setTextSize(10); but.setOnClickListener(new KvkButListener(res.getValue(r, "kvk"), res.getValue(r, "kvks"))); tr.addView(but); } else { tr.addView(new TextView(this)); } tr.addView(new TextView(this)); if (po != null) { Button but = new Button(this); but.setText("Postcode"); but.setTextSize(10); but.setOnClickListener(new PostcodeButListener(po)); tr.addView(but); } tl.addView(tr); } } } }
From source file:des.calculator.ui.MenuTabActivity.java
private void buildHistoryTable() { final int historySize = state.getHistoryLength(); TableRow currentRow = null;//from w w w . java 2 s .c o m // clear the table in case it has already been loaded. historyTable.removeAllViews(); // for each history entry for (int i = historySize - 1; i >= 0; i--) { // create the new row currentRow = new TableRow(this); //TableLayout.LayoutParams rowLayout = new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT); //rowLayout.setMargins(2, 2, 2, 2); //currentRow.setLayoutParams(rowLayout); //currentRow.setBackgroundColor(0xFF282828); currentRow.setBackgroundResource(R.layout.rowlayout); historyTable.addView(currentRow, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); // add the history info TextView entry = new TextView(this); entry.setText(state.getInputHistory(i)); entry.setGravity(Gravity.LEFT); entry.setTextSize(20); entry.setTextColor(0xFFFFFFFF); TextView answer = new TextView(this); answer.setText(state.getAnsHistory(i)); answer.setGravity(Gravity.RIGHT); answer.setWidth(30); answer.setTextSize(20); answer.setTextColor(0xFFFFFFFF); // create layout params for the text views TableRow.LayoutParams textLayout = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); textLayout.setMargins(4, 1, 4, 1); currentRow.addView(entry, textLayout); currentRow.addView(answer, textLayout); } }
From source file:nz.ac.auckland.lablet.script.SheetGroupLayoutParameters.java
@Override public View buildLayout(Context context, Fragment parentFragment) { layout = new TableLayout(context); layout.setStretchAllColumns(true);//w w w.j a va2s . c o m row = new TableRow(context); layout.addView(row); for (int i = 0; i < items.size(); i++) add(context, parentFragment, items.get(i), i == items.size() - 1); return layout; }
From source file:itesm.mx.golpedecalor.MonitoringActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_monitoring); alerta = false;/* ww w. j a v a 2 s. c om*/ dbo = new DataBaseOperations(getApplicationContext()); groupId = getIntent().getLongExtra("id", 0); // Referencias a objetos de interfacae tablaTL = (TableLayout) findViewById(R.id.tablaTL); nombreTV = (TextView) findViewById(R.id.nombreTV); causaTV = (TextView) findViewById(R.id.causaTV); parametroTV = (TextView) findViewById(R.id.parametroTV); switcherVS = (ViewSwitcher) findViewById(R.id.switcherVS); mp = MediaPlayer.create(this, R.raw.alert); recomendacionesTV = (TextView) findViewById(R.id.recomendacionesTV); // Inicializacin rc = new ArrayList<TextView>(); temp = new ArrayList<TextView>(); rad = new ArrayList<TextView>(); try { dbo.open(); } catch (SQLException ex) { Log.e("", ex.toString()); } grupo = dbo.getGroup(groupId); grupo.setIntegrantes(dbo.getAllUsersFromGroup(grupo)); monitoreoHelper = new Monitoreo(grupo, this); for (Usuario u : grupo.getIntegrantes()) { TableRow tr = new TableRow(this); tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.FILL_PARENT)); TextView tvAux = new TextView(this); tvAux.setText(u.getNombre() + " " + u.getApellidos()); tvAux.setLayoutParams(new TableRow.LayoutParams(400, TableRow.LayoutParams.WRAP_CONTENT)); TextView rcAux = new TextView(this); rcAux.setText("5"); rcAux.setLayoutParams(new TableRow.LayoutParams(200, TableRow.LayoutParams.WRAP_CONTENT)); TextView tempAux = new TextView(this); tempAux.setText("9"); tempAux.setLayoutParams(new TableRow.LayoutParams(200, TableRow.LayoutParams.WRAP_CONTENT)); TextView radAux = new TextView(this); radAux.setText("10"); radAux.setLayoutParams(new TableRow.LayoutParams(100, TableRow.LayoutParams.WRAP_CONTENT)); rc.add(rcAux); temp.add(tempAux); rad.add(radAux); tr.addView(tvAux); tr.addView(rcAux); tr.addView(tempAux); tr.addView(radAux); tr.setBackgroundResource(R.drawable.tabla); // Asigna recurso de drawable a la row nueva tablaTL.addView(tr); } monitoreoHelper.empezarMonitoreo(); notificationIntent = new Intent(getApplicationContext(), NotificationActivity.class); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); dialogClickListener = new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: monitoreoHelper.terminarAlerta(); break; case DialogInterface.BUTTON_NEGATIVE: //No button clicked break; } } }; }
From source file:com.example.hllut.app.Deprecated.MainActivity.java
/** * Fills "amount of planets" textView as well as drawing the planets */// w w w .ja v a 2s . c o m 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.photocitygame.android.ImageActivity.java
private void addScoreRow(TableLayout scoreTable, String team, int score) { TableRow row = new TableRow(this); TextView tv = new TextView(this); tv.setText(team);// w w w.ja v a 2s .co m row.addView(tv); TextView scoreView = new TextView(this); scoreView.setText(Integer.toString(score)); scoreView.setGravity(Gravity.RIGHT); row.addView(scoreView); scoreTable.addView(row); }
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 va2s.c om*/ 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:de.uulm.graphicalpasswords.openuyi.UYIPagerAdapter.java
@Override public Object instantiateItem(View collection, int pos) { LayoutInflater inflater = (LayoutInflater) collection.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); int page = 0; switch (pos) { case 1:/*w w w .j ava 2 s . c om*/ page = R.layout.uyipage2; break; case 2: page = R.layout.uyipage3; break; default: page = R.layout.uyipage1; break; } View view = inflater.inflate(page, null); TableLayout currentTable; switch (pos) { case 1: currentTable = (TableLayout) view.findViewById(R.id.uyi_tablelayout_page2); break; case 2: currentTable = (TableLayout) view.findViewById(R.id.uyi_tablelayout_page3); break; default: currentTable = (TableLayout) view.findViewById(R.id.uyi_tablelayout_page1); break; } // Add ImageButtons to TableLayout int index = 0; for (int i = 0; i < 3; i++) { TableRow currentRow = new TableRow(view.getContext()); for (int j = 0; j < 3; j++) { ImageButton button = new ImageButton(view.getContext()); button.setBackgroundColor(Color.TRANSPARENT); button.setPadding(3, 3, 3, 3); button.setAdjustViewBounds(true); button.setOnClickListener(clickListener); button.setImageResource(picture_arrays[pos][index]); button.setId(picture_arrays[pos][index]); button.setClickable(true); index++; currentRow.addView(button); } currentTable.addView(currentRow); } ((ViewPager) collection).addView(view, 0); return view; }