List of usage examples for android.widget TableLayout TableLayout
public TableLayout(Context context)
Creates a new TableLayout for the given context.
From source file:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java
/** Presents additional information about a specific assistant. * @return a dynamically generated linear layout *//*from w w w . ja v a 2 s. c o m*/ private LinearLayout getServiceDescLayout() { final LinearLayout output = new LinearLayout(this); final RelativeLayout topButtonsLayout = new RelativeLayout(this); RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); final Button btnBack = new Button(this); btnBack.setText(R.string.btnAllServices); btnBack.setId(5); btnBack.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { output.setVisibility(View.GONE); getListView().setVisibility(View.VISIBLE); lblAvAssist.setVisibility(View.VISIBLE); } }); topButtonsLayout.addView(btnBack); final Button btnInvoke = new Button(this); btnInvoke.setText(R.string.btnInvokeLabel); btnInvoke.setId(6); btnInvoke.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { new InvocationTask().execute(); } }); layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, btnInvoke.getId()); btnInvoke.setLayoutParams(layoutParams); topButtonsLayout.addView(btnInvoke); output.addView(topButtonsLayout); TableLayout serviceInfoTbl = new TableLayout(this); output.addView(serviceInfoTbl); serviceInfoTbl.setColumnShrinkable(1, true); /* FIRST ROW */ TableRow rowServiceName = new TableRow(this); TextView lblServiceName = new TextView(this); lblServiceName.setText(R.string.lblServiceName); lblServiceName.setTextAppearance(getApplicationContext(), R.style.titleText); TextView txtServiceName = new TextView(this); txtServiceName.setText(selectedService); txtServiceName.setTextAppearance(getApplicationContext(), R.style.normalText); txtServiceName.setPadding(10, 0, 0, 0); rowServiceName.addView(lblServiceName); rowServiceName.addView(txtServiceName); /* SECOND ROW */ TableRow rowServiceDesc = new TableRow(this); TextView lblServiceDesc = new TextView(this); lblServiceDesc.setText(R.string.lblServiceDesc); lblServiceDesc.setTextAppearance(getApplicationContext(), R.style.titleText); TextView txtServiceDesc = new TextView(this); txtServiceDesc.setTextAppearance(getApplicationContext(), R.style.normalText); txtServiceDesc.setPadding(10, 0, 0, 0); List<GateRuntimeParameter> params = null; ServiceInfoForClientArray list = getServices(); for (int i = 0; i < list.getItem().size(); i++) { if (list.getItem().get(i).getServiceName().equals(selectedService)) { txtServiceDesc.setText(list.getItem().get(i).getServiceDescription()); params = list.getItem().get(i).getParams(); break; } } TextView lblParams = new TextView(this); lblParams.setText(R.string.lblServiceParams); lblParams.setTextAppearance(getApplicationContext(), R.style.titleText); output.addView(lblParams); LayoutParams txtParamsAttrbs = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout paramsLayout = new LinearLayout(this); paramsLayout.setId(0); if (params.size() > 0) { ScrollView scroll = new ScrollView(this); scroll.setLayoutParams(txtParamsAttrbs); paramsLayout.setOrientation(LinearLayout.VERTICAL); scroll.addView(paramsLayout); for (int j = 0; j < params.size(); j++) { TextView lblParamName = new TextView(this); lblParamName.setText(params.get(j).getParamName()); EditText tview = new EditText(this); tview.setId(1); tview.setText(params.get(j).getDefaultValueString()); LayoutParams txtViewLayoutParams = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); tview.setLayoutParams(txtViewLayoutParams); paramsLayout.addView(lblParamName); paramsLayout.addView(tview); } output.addView(scroll); } else { TextView lblParamName = new TextView(this); lblParamName.setText(R.string.lblRTParams); output.addView(lblParamName); } rowServiceDesc.addView(lblServiceDesc); rowServiceDesc.addView(txtServiceDesc); serviceInfoTbl.addView(rowServiceName); serviceInfoTbl.addView(rowServiceDesc); output.setOrientation(LinearLayout.VERTICAL); output.setGravity(Gravity.TOP); return output; }
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 w ww . ja va 2s . c o m*/ 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.near.chimerarevo.fragments.PostFragment.java
private void parseTables(Elements tbls) { TableLayout tl = new TableLayout(getActivity()); LayoutParams tl_prms = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); tl_prms.gravity = Gravity.CENTER_HORIZONTAL; tl_prms.setMargins(10, 10, 10, 0);//from w w w . j a v a 2s . c o m tl.setLayoutParams(tl_prms); for (Element tbl : tbls) { Elements rws = tbl.getElementsByTag("td"); TableRow row = new TableRow(getActivity()); for (Element rw : rws) { TextView txt = new TextView(getActivity()); txt.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT, TableRow.LayoutParams.WRAP_CONTENT)); txt.setText(rw.text()); row.addView(txt); } tl.addView(row); } lay.addView(tl); }
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 w ww .j av a 2 s . c o m*/ 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:com.adarshahd.indianrailinfo.donate.TrainDetails.java
private void createTableLayoutTrainFare() { if (mPage.contains("SORRY")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Not a valid class, Please select a different class and try again."); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews();//from w ww . java 2s .com mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("ISL Of")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Station is not in ISL Of the Train. \nPlease modify the source/destination!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("ERROR")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Your request resulted in an error.\nPlease check!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("Network Connectivity")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Looks like the server is busy.\nPlease try later!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("unavailable")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText( "Response from server:\n\nYour request could not be processed now. \nPlease try again later!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mDetails == null || !mDetails.getTrainNumber().equals(mTrainNumber)) { Iterator iterator = null; try { iterator = mElements.first().parent().parent().parent().getElementsByTag("tr").iterator(); } catch (Exception e) { Log.i("TrainDetails", mPage); } mListFr = new ArrayList<List<String>>(); List<String> list; Element tmp; while (iterator.hasNext()) { tmp = (Element) iterator.next(); list = new ArrayList<String>(); list.add(tmp.select("td").get(0).text()); list.add(tmp.select("td").get(1).text()); mListFr.add(list); } mDetails = new Details(mListFr, TrainEnquiry.FARE, mTrainNumber); } else { mListFr = mDetails.getList(); } mTblLayoutFr = new TableLayout(mActivity); TableRow row; TextView tv1, tv2; mTblLayoutFr.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); for (int i = 0; i < mListFr.size(); i++) { row = new TableRow(mActivity); tv1 = new TextView(mActivity); tv2 = new TextView(mActivity); tv1.setText(" " + mListFr.get(i).get(0)); tv2.setText(" " + mListFr.get(i).get(1)); tv1.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv2.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Medium); tv1.setPadding(5, 5, 5, 5); tv2.setPadding(5, 5, 5, 5); /*tv2.setBackgroundResource(R.drawable.card_divider); tv3.setBackgroundResource(R.drawable.card_divider); tv4.setBackgroundResource(R.drawable.card_divider);*/ row.addView(tv1); row.addView(tv2); row.setBackgroundResource(R.drawable.button_selector); row.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); mTblLayoutFr.addView(row); } LinearLayout ll = new LinearLayout(mActivity); ScrollView scrollView = new ScrollView(mActivity); TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Fare details:"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); ll.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(textViewTrnDtls); ll.addView(mTblLayoutFr); scrollView.addView(ll); mFrameLayout.removeAllViews(); mFrameLayout.addView(scrollView); if (mDialog.isShowing()) { mDialog.cancel(); } }
From source file:com.vonglasow.michael.satstat.MainActivity.java
private final void addWifiResult(ScanResult result) { final ScanResult r = result; android.view.View.OnClickListener clis = new android.view.View.OnClickListener() { @Override/*from w ww .j a v a 2s.c o m*/ public void onClick(View v) { onWifiEntryClick(r.BSSID); } }; View divider = new View(wifiAps.getContext()); divider.setLayoutParams(new TableRow.LayoutParams(LayoutParams.MATCH_PARENT, 1)); divider.setBackgroundColor(getResources().getColor(android.R.color.tertiary_text_dark)); divider.setOnClickListener(clis); wifiAps.addView(divider); LinearLayout wifiLayout = new LinearLayout(wifiAps.getContext()); wifiLayout.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); wifiLayout.setOrientation(LinearLayout.HORIZONTAL); wifiLayout.setWeightSum(22); wifiLayout.setMeasureWithLargestChildEnabled(false); ImageView wifiType = new ImageView(wifiAps.getContext()); wifiType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 3)); if (WifiCapabilities.isAdhoc(result)) { wifiType.setImageResource(R.drawable.ic_content_wifi_adhoc); } else if ((WifiCapabilities.isEnterprise(result)) || (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.EAP)) { wifiType.setImageResource(R.drawable.ic_content_wifi_eap); } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.PSK) { wifiType.setImageResource(R.drawable.ic_content_wifi_psk); } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.WEP) { wifiType.setImageResource(R.drawable.ic_content_wifi_wep); } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.OPEN) { wifiType.setImageResource(R.drawable.ic_content_wifi_open); } else { wifiType.setImageResource(R.drawable.ic_content_wifi_unknown); } wifiType.setScaleType(ScaleType.CENTER); wifiLayout.addView(wifiType); TableLayout wifiDetails = new TableLayout(wifiAps.getContext()); wifiDetails.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19)); TableRow innerRow1 = new TableRow(wifiAps.getContext()); TextView newMac = new TextView(wifiAps.getContext()); newMac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 14)); newMac.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium); newMac.setText(result.BSSID); innerRow1.addView(newMac); TextView newCh = new TextView(wifiAps.getContext()); newCh.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2)); newCh.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium); newCh.setText(getChannelFromFrequency(result.frequency)); innerRow1.addView(newCh); TextView newLevel = new TextView(wifiAps.getContext()); newLevel.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3)); newLevel.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium); newLevel.setText(String.valueOf(result.level)); innerRow1.addView(newLevel); innerRow1.setOnClickListener(clis); wifiDetails.addView(innerRow1, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); TableRow innerRow2 = new TableRow(wifiAps.getContext()); TextView newSSID = new TextView(wifiAps.getContext()); newSSID.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19)); newSSID.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Small); newSSID.setText(result.SSID); innerRow2.addView(newSSID); innerRow2.setOnClickListener(clis); wifiDetails.addView(innerRow2, new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); wifiLayout.addView(wifiDetails); wifiLayout.setOnClickListener(clis); wifiAps.addView(wifiLayout); }
From source file:com.adarshahd.indianrailinfo.donate.TrainDetails.java
private void createTableLayoutTrainAvailability() { if (mPage.contains("SORRY")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Not a valid class, Please select a different class and try again."); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews();/*from w w w . ja v a 2 s . c o m*/ mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("ISL Of")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Station is not in ISL Of the Train. \nPlease modify the source/destination!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("ERROR")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Your request resulted in an error.\nPlease check!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("Network Connectivity")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Looks like the server is busy.\nPlease try later!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mPage.contains("unavailable")) { TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText( "Response from server:\n\nYour request could not be processed now.\nPlease try again later!"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); textViewTrnDtls.setTextColor(Color.RED); mFrameLayout.removeAllViews(); mFrameLayout.addView(textViewTrnDtls); if (mDialog.isShowing()) { mDialog.cancel(); } return; } if (mDetails == null || !mDetails.getTrainNumber().equals(mTrainNumber)) { Iterator iterator = null; try { iterator = mElements.first().parent().parent().parent().getElementsByTag("tr").iterator(); } catch (Exception e) { Log.i("TrainDetails", mPage); e.printStackTrace(); return; } mListAv = new ArrayList<List<String>>(); List<String> list; Element tmp; tmp = (Element) iterator.next(); list = new ArrayList<String>(); list.add(tmp.select("th").get(0).text()); list.add("Date"); list.add(tmp.select("th").get(2).text()); //list.add(tmp.select("th").get(3).text()); mListAv.add(list); while (iterator.hasNext()) { tmp = (Element) iterator.next(); if (!tmp.hasText()) { continue; } 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()); //list.add(tmp.select("td").get(3).text()); mListAv.add(list); } mDetails = new Details(mListAv, TrainEnquiry.AVAILABILITY, mTrainNumber); } else { mListAv = mDetails.getList(); } mTblLayoutAv = new TableLayout(mActivity); TableRow row; TextView tv1, tv2, tv3; mTblLayoutAv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); for (int i = 0; i < mListAv.size(); i++) { row = new TableRow(mActivity); tv1 = new TextView(mActivity); tv2 = new TextView(mActivity); tv3 = new TextView(mActivity); //tv4 = new TextView(mActivity); tv1.setText(" " + mListAv.get(i).get(0)); tv2.setText(" " + mListAv.get(i).get(1)); tv3.setText(" " + mListAv.get(i).get(2)); //tv4.setText(" " + mListAv.get(i).get(3)); 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(5, 5, 5, 5); tv2.setPadding(5, 5, 5, 5); tv3.setPadding(5, 5, 5, 5); //tv4.setPadding(5,5,5,5); /*tv2.setBackgroundResource(R.drawable.card_divider); tv3.setBackgroundResource(R.drawable.card_divider); tv4.setBackgroundResource(R.drawable.card_divider);*/ row.addView(tv1); row.addView(tv2); row.addView(tv3); //row.addView(tv4); row.setBackgroundResource(R.drawable.button_selector); row.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); row.setOnClickListener(this); mTblLayoutAv.addView(row); } LinearLayout ll = new LinearLayout(mActivity); ScrollView scrollView = new ScrollView(mActivity); TextView textViewTrnDtls = new TextView(mActivity); textViewTrnDtls.setText("Availability details:"); textViewTrnDtls.setTextAppearance(mActivity, android.R.style.TextAppearance_DeviceDefault_Large); textViewTrnDtls.setPadding(10, 10, 10, 10); ll.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); ll.setOrientation(LinearLayout.VERTICAL); ll.addView(textViewTrnDtls); ll.addView(mTblLayoutAv); scrollView.addView(ll); mFrameLayout.removeAllViews(); mFrameLayout.addView(scrollView); if (mDialog.isShowing()) { mDialog.cancel(); } }