Example usage for android.widget TableRow setBackgroundResource

List of usage examples for android.widget TableRow setBackgroundResource

Introduction

In this page you can find the example usage for android.widget TableRow setBackgroundResource.

Prototype

@RemotableViewMethod
public void setBackgroundResource(@DrawableRes int resid) 

Source Link

Document

Set the background to a given resource.

Usage

From source file:des.calculator.ui.MenuTabActivity.java

private void buildHistoryTable() {
    final int historySize = state.getHistoryLength();

    TableRow currentRow = null;
    // clear the table in case it has already been loaded.
    historyTable.removeAllViews();//from   w ww  .jav  a  2 s .  c o  m
    // 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:de.domjos.schooltools.activities.MainActivity.java

public static void initTimes(TableLayout grid) {
    Map<Double, Hour> times = new TreeMap<>();
    List<Hour> hours = MainActivity.globals.getSqLite().getHours("");
    for (Hour hour : hours) {
        times.put(Double.parseDouble(hour.getStart().replace(":", ".")), hour);
    }/*w  ww  .  jav a2  s  .c om*/

    List hourList = Arrays.asList(times.values().toArray());
    int max = hourList.size() - 1;
    for (int i = 1; i <= grid.getChildCount() - 1; i++) {
        TableRow row = (TableRow) grid.getChildAt(i);
        TextView textView = (TextView) row.getChildAt(0);
        if ((i - 1) <= max) {
            Hour hour = (Hour) hourList.get(i - 1);
            textView.setText(String.format("%s%n%s", hour.getStart(), hour.getEnd()));
            textView.setTag(String.valueOf(hour.getID()));

            if (hour.isBreak()) {
                textView.setTextSize(14);
                textView.setText(textView.getText().toString().replace("\n", ":"));
                for (int j = 1; j <= row.getChildCount() - 1; j++) {
                    row.getChildAt(j).setBackgroundColor(Color.TRANSPARENT);
                    row.setBackgroundResource(R.drawable.tbl_border);
                }
            }
        } else {
            grid.getChildAt(i).setVisibility(View.GONE);
        }
    }
}

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:itesm.mx.golpedecalor.MonitoringActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_monitoring);

    alerta = false;// w  w w . j  av a2 s  . c o  m

    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.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  w w. j  a va  2s  . co 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);
        }
        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.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  w  w. j a  v  a2 s  . 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.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  ww  .  j a va  2  s . 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);
            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();
    }
}

From source file:com.orange.ocara.ui.activity.ResultAuditActivity.java

private View buildResumeRow(RequestCreator handicapIconRequest, String handicapName, AccessibilityStats stats,
        int rowIndex) {

    TableRow row = (TableRow) getLayoutInflater().inflate(com.orange.ocara.R.layout.result_resume_item, null);

    TextView noImpact = (TextView) row.findViewById(com.orange.ocara.R.id.resume_handicap_no_impact);
    TextView annoying = (TextView) row.findViewById(com.orange.ocara.R.id.resume_handicap_annoying);
    TextView blocking = (TextView) row.findViewById(com.orange.ocara.R.id.resume_handicap_blocking);
    TextView doubt = (TextView) row.findViewById(com.orange.ocara.R.id.resume_handicap_doubt);

    noImpact.setText(Integer.toString(stats.getCounter(AccessibilityStats.Type.ACCESSIBLE)));
    annoying.setText(Integer.toString(stats.getCounter(AccessibilityStats.Type.ANNOYING)));
    blocking.setText(Integer.toString(stats.getCounter(AccessibilityStats.Type.BLOCKING)));
    doubt.setText(Integer.toString(stats.getCounter(AccessibilityStats.Type.DOUBT)));

    final TextView handicapType = (TextView) row.findViewById(com.orange.ocara.R.id.resume_handicap_type);
    handicapType.setText(handicapName);/*  ww w .  jav  a2 s  . c o  m*/
    if (handicapIconRequest != null) {

        Target target = new Target() {
            @Override
            public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                handicapType.setCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(getResources(), bitmap),
                        null, null, null);
            }

            @Override
            public void onBitmapFailed(Drawable errorDrawable) {
            }

            @Override
            public void onPrepareLoad(Drawable placeHolderDrawable) {
            }
        };
        final int maxSize = getResources()
                .getDimensionPixelSize(com.orange.ocara.R.dimen.resultResumeHandicapIconSize);
        handicapIconRequest.placeholder(android.R.color.black).resize(maxSize, maxSize).into(target);
    }

    int backGroundColor = (rowIndex % 2 == 0) ? com.orange.ocara.R.color.resultTableColorEven
            : com.orange.ocara.R.color.resultTableColorOdd;
    row.setBackgroundResource(backGroundColor);

    return row;
}