Example usage for android.widget TableRow addView

List of usage examples for android.widget TableRow addView

Introduction

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

Prototype

public void addView(View child) 

Source Link

Document

Adds a child view.

Usage

From source file:de.eidottermihi.rpicheck.activity.MainActivity.java

private View createDiskRow(DiskUsageBean disk) {
    final TableRow tempRow = new TableRow(this);
    tempRow.addView(createTextView(disk.getFileSystem()));
    tempRow.addView(createTextView(disk.getSize()));
    tempRow.addView(createTextView(disk.getAvailable()));
    tempRow.addView(createTextView(disk.getUsedPercent()));
    tempRow.addView(createTextView(disk.getMountedOn()));
    return tempRow;
}

From source file:com.example.parkhere.seeker.SeekerProfileVehicleFragment.java

public void getCurrInfo() {
    tag = 1;//w  w w  .  ja va  2 s  . c o  m

    Retrofit retrofit = new Retrofit.Builder().baseUrl(Constants.BASE_URL)
            .addConverterFactory(GsonConverterFactory.create()).build();

    RequestInterface requestInterface = retrofit.create(RequestInterface.class);

    ServerRequest request = new ServerRequest();
    request.setOperation(Constants.GET_SEEKER_PROFILE_OPERATION);
    request.setUser(user);
    Call<ServerResponse> response = requestInterface.operation(request);

    response.enqueue(new Callback<ServerResponse>() {
        @Override
        public void onResponse(Call<ServerResponse> call, retrofit2.Response<ServerResponse> response) {
            ServerResponse resp = response.body();

            if (resp.getResult().equals(Constants.SUCCESS)) {
                vehicles = resp.getVehicles();

                TableRow tr_head = new TableRow(myContext);
                tr_head.setBackgroundColor(Color.GRAY);
                tr_head.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,
                        TableRow.LayoutParams.WRAP_CONTENT));

                TextView make = new TextView(myContext);
                make.setText("MAKE");
                make.setTextColor(Color.WHITE);
                make.setPadding(5, 5, 5, 5);
                tr_head.addView(make);

                TextView model = new TextView(myContext);
                model.setText("MODEL");
                model.setTextColor(Color.WHITE);
                model.setPadding(5, 5, 5, 5);
                tr_head.addView(model);

                final TextView license = new TextView(myContext);
                license.setText("LICENSE PLATE");
                license.setTextColor(Color.WHITE);
                license.setPadding(5, 5, 5, 5);
                tr_head.addView(license);

                tl.addView(tr_head, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT,
                        TableLayout.LayoutParams.WRAP_CONTENT));

                for (int i = 0; i < vehicles.length; i++) {
                    if (vehicles[i].getDeletedWithHistory() == 1) {
                        continue;
                    }

                    TableRow tr = new TableRow(myContext);
                    tr.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.FILL_PARENT,
                            TableRow.LayoutParams.WRAP_CONTENT));
                    tr.setTag(tag);
                    tag++;
                    tr.setClickable(true);
                    tr.setOnClickListener(clickListener);

                    TextView v_make = new TextView(myContext);
                    v_make.setText(vehicles[i].getMake());
                    v_make.setLayoutParams(new TableRow.LayoutParams(300, 150));
                    tr.addView(v_make);

                    TextView v_model = new TextView(myContext);
                    v_model.setText(vehicles[i].getModel());
                    v_model.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                            TableRow.LayoutParams.WRAP_CONTENT));
                    tr.addView(v_model);

                    TextView v_license = new TextView(myContext);
                    v_license.setText(vehicles[i].getLicensePlate());
                    v_license.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
                            TableRow.LayoutParams.WRAP_CONTENT));
                    tr.addView(v_license);

                    tl.addView(tr, new TableLayout.LayoutParams(TableLayout.LayoutParams.FILL_PARENT,
                            TableLayout.LayoutParams.WRAP_CONTENT));
                }
            }
        }

        @Override
        public void onFailure(Call<ServerResponse> call, Throwable t) {
            Snackbar.make(rootView, t.getLocalizedMessage(), Snackbar.LENGTH_LONG).show();
        }
    });
}

From source file:de.eidottermihi.rpicheck.activity.MainActivity.java

private View createNetworkRow(NetworkInterfaceInformation interfaceInformation) {
    final TableRow tempRow = new TableRow(this);
    tempRow.addView(createTextView(interfaceInformation.getName()));
    CharSequence statusText;//from  w  w w.ja  va  2s . co m
    if (interfaceInformation.isHasCarrier()) {
        statusText = getText(R.string.network_status_up);
    } else {
        statusText = getText(R.string.network_status_down);
    }
    tempRow.addView(createTextView(statusText.toString()));
    if (interfaceInformation.getIpAdress() != null) {
        tempRow.addView(createTextView(interfaceInformation.getIpAdress()));
    } else {
        tempRow.addView(createTextView(" - "));
    }
    if (interfaceInformation.getWlanInfo() != null) {
        final WlanBean wlan = interfaceInformation.getWlanInfo();
        tempRow.addView(createTextView(FormatHelper.formatPercentage(wlan.getSignalLevel())));
        tempRow.addView(createTextView(FormatHelper.formatPercentage(wlan.getLinkQuality())));
    } else {
        tempRow.addView(createTextView(" - "));
        tempRow.addView(createTextView(" - "));
    }
    return tempRow;
}

From source file:edu.cwru.apo.Directory.java

private void loadTable() {
    ProgressDialog progDialog = ProgressDialog.show(this, "Loading", "Please Wait", false);
    userTable.removeAllViews();//from   ww  w  .j  a v a  2 s  .  c  o m
    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: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  ww  w  .j av a2s. 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:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java

/** Presents additional information about a specific assistant.
 * @return a dynamically generated linear layout
 *//*from ww  w.  java 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 createTableLayoutTrnDtls() {
    if (mPageResult.contains("FLUSHED PNR / ") || mPageResult.contains("Invalid PNR")) {
        mTextViewPNRSts.setText("The PNR entered is either invalid or expired! Please check.");
        mFrameLayout.removeAllViews();//  w w w . ja va2 s .co  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.vonglasow.michael.satstat.ui.RadioSectionFragment.java

private final void addWifiResult(ScanResult result) {
    // needed to pass a persistent reference to the OnClickListener
    final ScanResult r = result;
    android.view.View.OnClickListener clis = new android.view.View.OnClickListener() {

        @Override/*from   w  w w  .jav  a  2s .  co  m*/
        public void onClick(View v) {
            onWifiEntryClick(r.BSSID);
        }
    };

    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:mx.udlap.is522.tedroid.activity.ScoresActivity.java

/**
 * Convierte un objeto Score en objeto TableRow.
 * //www.j av a 2s .  co  m
 * @param score el objeto Score a convertir.
 * @return un objeto TableRow.
 */
private TableRow toTableRow(Score score) {
    TableRow row = new TableRow(this);
    TextView pointsText = new TextView(this);
    pointsText.setText(String.valueOf(score.getPoints()));
    applySecondaryStyleTo(pointsText);
    pointsText.setLayoutParams(layoutParams);
    TextView levelText = new TextView(this);
    levelText.setText(String.valueOf(score.getLevel()));
    applySecondaryStyleTo(levelText);
    TextView linesText = new TextView(this);
    linesText.setText(String.valueOf(score.getLines()));
    applySecondaryStyleTo(linesText);
    TextView dateText = new TextView(this);
    String dateStr = getString(R.string.datetime_format,
            DateFormat.getDateFormat(getApplicationContext()).format(score.getObtainedAt()),
            DateFormat.getTimeFormat(getApplicationContext()).format(score.getObtainedAt()));
    dateText.setText(dateStr);
    applySecondaryStyleTo(dateText);
    row.addView(pointsText);
    row.addView(levelText);
    row.addView(linesText);
    row.addView(dateText);
    return row;
}

From source file:org.mythdroid.activities.Guide.java

/**
 * Get a header row containing column time values
 * @return header TableRow//  www  .  j av  a 2  s.c om
 */
private TableRow getHeader() {

    final TableRow row = new TableRow(this, null);
    TextView tv = new TextView(this, null);
    tv.setLayoutParams(hdrDateLayout);
    tv.setPadding(4, 4, 4, 4);
    tv.setBackgroundColor(0xffd0d0ff);
    tv.setTextColor(0xff161616);
    tv.setMaxLines(1);
    tv.setText(hdrDate);
    row.addView(tv);

    int j = 0;

    for (int i = 1; i < times.length; i += hdrSpan) {
        tv = new TextView(this, null);
        tv.setLayoutParams(hdrTimeLayout);
        tv.setPadding(4, 4, 4, 4);
        tv.setBackgroundColor(0xffd0d0ff);
        tv.setTextColor(0xff161616);
        tv.setMaxLines(1);
        tv.setText(hdrTimes[j++]);
        row.addView(tv);
    }

    return row;

}