Example usage for android.widget TableLayout addView

List of usage examples for android.widget TableLayout addView

Introduction

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

Prototype

@Override
public void addView(View child) 

Source Link

Usage

From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java

private void addGridItem(String timestamp, String location, String result, int grid) {
    TableLayout table = (TableLayout) findViewById(grid);
    TableLayout row = (TableLayout) LayoutInflater.from(SamKnowsAggregateStatViewerActivity.this)
            .inflate(R.layout.stat_grid, null);

    ((TextView) row.findViewById(R.id.stat_grid_timestamp)).setText(timestamp);
    ((TextView) row.findViewById(R.id.stat_grid_location)).setText(location);
    ((TextView) row.findViewById(R.id.stat_grid_result)).setText(result);

    table.addView(row);
}

From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java

private void addGridItemFailed(String timestamp, String location, String result, int grid) {
    TableLayout table = (TableLayout) findViewById(grid);
    TableLayout row = (TableLayout) LayoutInflater.from(SamKnowsAggregateStatViewerActivity.this)
            .inflate(R.layout.stat_grid_fail, null);

    ((TextView) row.findViewById(R.id.stat_grid_timestamp)).setText(timestamp);
    ((TextView) row.findViewById(R.id.stat_grid_location)).setText(location);
    ((TextView) row.findViewById(R.id.stat_grid_result)).setText(result);

    table.addView(row);
}

From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java

private void addGridItemHeader(String timestamp, String location, String result, int grid) {
    TableLayout table = (TableLayout) findViewById(grid);
    TableLayout row = (TableLayout) LayoutInflater.from(SamKnowsAggregateStatViewerActivity.this)
            .inflate(R.layout.stat_grid_header, null);

    ((TextView) row.findViewById(R.id.stat_grid_timestamp)).setText(timestamp);
    ((TextView) row.findViewById(R.id.stat_grid_location)).setText(location);
    ((TextView) row.findViewById(R.id.stat_grid_result)).setText(result);

    table.addView(row);
}

From source file:se.frikod.payday.DailyBudgetFragment.java

private void updateBudgetItems() {

    TableLayout itemsTable = (TableLayout) V.findViewById(R.id.budgetItems);
    itemsTable.removeAllViews();//w w w . j a v  a  2 s  .  com

    for (int i = 0; i < budget.budgetItems.size(); i++) {
        BudgetItem bi = budget.budgetItems.get(i);
        final int currentIndex = i;
        LayoutInflater inflater = activity.getLayoutInflater();
        TableRow budgetItemView = (TableRow) inflater.inflate(R.layout.daily_budget_budget_item, itemsTable,
                false);

        TextView amount = (TextView) budgetItemView.findViewById(R.id.budgetItemAmount);
        TextView title = (TextView) budgetItemView.findViewById(R.id.budgetItemLabel);

        amount.setText(budget.formatter.format(bi.amount));

        title.setText(bi.title);

        if (bi.exclude) {
            amount.setTextColor(0xffCCCCCC);
            amount.setPaintFlags(amount.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);

            title.setTextColor(0xffCCCCCC);
            title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
        }

        budgetItemView.setClickable(true);
        budgetItemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
                vibrator.vibrate(10);

                BudgetItem bi = budget.budgetItems.get(currentIndex);
                bi.exclude = !bi.exclude;
                budget.saveBudgetItems();
                updateBudgetItems();
            }
        });

        budgetItemView.setLongClickable(true);
        budgetItemView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                editBudgetItem(v, currentIndex);
                return true;
            }
        });
        itemsTable.addView(budgetItemView);
    }

    FontUtils.setRobotoFont(activity, itemsTable);
    updateBudget();
}

From source file:de.ribeiro.android.gso.dataclasses.Pager.java

/**
 * Erstellt eine Stundeplan Seite des ViewPagers, inkl Header und Footer
 * <p/>//from   ww  w  . j a v a2  s  .  c o  m
 * Hier wird die Wochenansicht generiert
 *
 * @param weekData
 * @param ctxt
 * @return
 * @author Tobias Janssen
 */
private View createWeekPage(WeekData weekData) {
    // in die Page kommen alle Elemente dieser Ansicht
    View page = inflater.inflate(R.layout.weeklayout, null);

    TableLayout tl = (TableLayout) page.findViewById(R.id.weekTimetable);
    LinearLayoutBordered ll = new LinearLayoutBordered(context);

    // Tagesberschrift erstellen:
    TableRow tr = new TableRow(context);

    for (int x = Calendar.SUNDAY; x < Calendar.SATURDAY; x++) {
        // einen neuen Rahmen fr das Tabellenfeld vorbereiten
        ll = new LinearLayoutBordered(context);
        ll.setBorderRight(true);
        ll.setBorderBottom(true);
        ll.setBorderTop(true);
        ll.setBorderSize(1);
        ll.setBackgroundColor(Color.WHITE);

        View textview = inflater.inflate(R.layout.textview, null);
        TextView tv = (TextView) textview.findViewById(R.id.textview);
        // berschriftentextgre einstellen

        tv.setTextSize(textSize);
        if (x == Calendar.SUNDAY) {
            tv.setText(timeslots[0]);
            tv.setTextColor(Color.parseColor("#3A599A"));

        } else {
            tv.setText(ResolveWeekDay(x));
        }
        ll.addView(tv);
        tr.addView(ll);
    }
    tl.addView(tr);

    // den Stundenplan zusammensetzten
    // fr jeden tag
    List<Lesson> stunden = GetSchulstunden();
    for (int y = 0; y < stunden.size(); y++) {
        tr = new TableRow(context);
        for (int x = Calendar.SUNDAY; x <= Calendar.FRIDAY; x++) {
            if (x == Calendar.SUNDAY) {
                addColumn(timeslots[y + 1], "#3A599A", tr);
            } else {
                // alle events dieses Tages durchgehen ob die zu dieser
                // schulstunde passen
                boolean lessonAdded = false;
                TextView lastTextView = null;
                for (ICalEvent ev : weekData.events) {
                    // ist event an diesem tag?
                    if (ev.DTSTART.get(Calendar.DAY_OF_WEEK) == x) {
                        // ja
                        // ist event zu dieser schulstunde?

                        Time st = new Time();
                        st.set(ev.DTSTART.getTimeInMillis());
                        int start = GetSchulstundeOfDateTime(st);
                        Time et = new Time();
                        et.set(ev.DTEND.getTimeInMillis() - 60000);
                        int end = GetSchulstundeOfDateTime(et);
                        // ende der schulstunde herausfinden
                        if (((start != end) && y >= start && y <= end) || start == y || end == y) {
                            // ja event ist in dieser stunde
                            // ist eine Doopelbelegung fr diese Stunde?
                            if (lessonAdded && lastTextView != null) {
                                // ja, doppelbelegung
                                String newText = "";
                                if (weekData.typeId.equalsIgnoreCase("4")) {
                                    newText = lastTextView.getText() + "\r\n" + ev.DESCRIPTION + " "
                                            + ev.SUMMARY;
                                } else {
                                    newText = lastTextView.getText() + "\r\n"
                                            + ev.DESCRIPTION.replace(weekData.elementId, "") + " " + ev.SUMMARY
                                            + " " + ev.LOCATION;
                                }
                                lastTextView.setText(newText);
                            } else {
                                // prfen, ob dieses event eine gelschte
                                // stunde ist
                                if (ev.UID.equalsIgnoreCase("deleted")) {
                                    // gelschtes event
                                    lastTextView = addColumn(" --- " + " " + " --- " + " " + " --- ", "#FF0000",
                                            tr);
                                } else {
                                    String color = "#3A599A";
                                    if (ev.UID.equalsIgnoreCase("diff"))
                                        color = "#FF0000";
                                    if (weekData.typeId.equalsIgnoreCase("4")) {
                                        lastTextView = addColumn(ev.DESCRIPTION + " " + ev.SUMMARY, color, tr);
                                    } else {
                                        lastTextView = addColumn(ev.DESCRIPTION.replace(weekData.elementId, "")
                                                + " " + ev.SUMMARY + " " + ev.LOCATION, color, tr);
                                    }
                                }
                            }

                            lessonAdded = true;
                        }
                    }
                }
                if (!lessonAdded) {
                    // ja event ist in dieser stunde
                    addColumn("", "#3A599A", tr);
                }
            }
        }
        tl.addView(tr);
    }
    TextView syncTime = (TextView) page.findViewById(R.id.syncTime);
    Calendar sync = new GregorianCalendar();
    sync.setTimeInMillis(weekData.syncTime);

    String minute = String.valueOf(sync.get(Calendar.MINUTE));
    if (minute.length() == 1)
        minute = "0" + minute;

    syncTime.setText(weekData.elementId + " | Stand vom " + sync.get(Calendar.DAY_OF_MONTH) + "."
            + (sync.get(Calendar.MONTH) + 1) + "." + sync.get(Calendar.YEAR) + " "
            + sync.get(Calendar.HOUR_OF_DAY) + ":" + minute + " Uhr");

    return page;
}

From source file:com.ehret.mixit.fragment.SessionDetailFragment.java

private void addSpeakerInfo(Talk conference) {
    //On vide les lments
    sessionPersonList.removeAllViews();//from w ww .jav  a 2s  .  co m

    List<Member> speakers = new ArrayList<>();
    for (Speaker member : conference.getSpeakers()) {
        Member membre = MembreFacade.getInstance().getMembre(getActivity(), TypeFile.speaker.name(),
                member.getIdMember());

        if (membre != null) {
            speakers.add(membre);
        }
    }

    //On affiche les liens que si on a recuperer des choses
    if (!speakers.isEmpty()) {
        //On utilisait auparavant une liste pour afficher ces lments dans la page mais cette liste
        //empche d'avoir un ScrollView englobant pour toute la page. Nous utilisons donc un tableau

        //On ajoute un table layout
        TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
                TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
        TableLayout tableLayout = new TableLayout(getActivity().getBaseContext());
        tableLayout.setLayoutParams(tableParams);

        if (mInflater != null) {
            for (final Member membre : speakers) {
                LinearLayout row = (LinearLayout) mInflater.inflate(R.layout.item_person, tableLayout, false);
                row.setBackgroundResource(R.drawable.row_transparent_background);

                //Dans lequel nous allons ajouter le contenu que nous faisons mapp dans
                TextView userName = (TextView) row.findViewById(R.id.person_user_name);
                TextView descriptif = (TextView) row.findViewById(R.id.person_shortdesciptif);
                TextView level = (TextView) row.findViewById(R.id.person_level);
                ImageView profileImage = (ImageView) row.findViewById(R.id.person_user_image);

                userName.setText(membre.getCompleteName());

                if (membre.getShortDescription() != null) {
                    descriptif.setText(membre.getShortDescription().trim());
                }

                //Recuperation de l'mage liee au profil
                Bitmap image = FileUtils.getImageProfile(getActivity(), membre);
                if (image == null) {
                    profileImage.setImageDrawable(getResources().getDrawable(R.drawable.person_image_empty));
                } else {
                    //On regarde dans les images embarquees
                    profileImage.setImageBitmap(image);
                }

                row.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        ((HomeActivity) getActivity()).changeCurrentFragment(PeopleDetailFragment
                                .newInstance(TypeFile.speaker.toString(), membre.getLogin(), 7),
                                TypeFile.speaker.toString());
                    }
                });

                tableLayout.addView(row);
            }
        }
        sessionPersonList.addView(tableLayout);
    }
}

From source file:info.semanticsoftware.semassist.android.activity.SemanticResultsActivity.java

/** Presents the results in a list format.
 * @param savedInstanceState saved instance state
 *//* w ww  . j  a  va2  s  .  co  m*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    String resultsXML = getIntent().getStringExtra("xml");
    Vector<SemanticServiceResult> results = ClientUtils.getServiceResults(resultsXML);
    setContentView(R.layout.results);

    TableLayout tblResults = (TableLayout) findViewById(R.id.tblResultsLayout);
    tblResults.setStretchAllColumns(true);

    TableRow resultRow;
    TextView txtContent;
    TextView txtType;
    TextView txtStart;
    TextView txtEnd;
    TextView txtFeats;

    if (results == null) {
        // handle server errors
    } else {
        for (SemanticServiceResult current : results) {
            if (current.mResultType.equals(SemanticServiceResult.ANNOTATION)) {

                List<AnnotationInstance> annots = ServerResponseHandler.createAnnotation(current);
                for (int i = 0; i < annots.size(); i++) {
                    resultRow = new TableRow(getApplicationContext());

                    txtContent = new TextView(getApplicationContext());
                    txtContent.setText(annots.get(i).getContent());
                    txtContent.setTextAppearance(getApplicationContext(), R.style.normalText);
                    resultRow.addView(txtContent);

                    txtType = new TextView(getApplicationContext());
                    txtType.setText(annots.get(i).getType());
                    txtType.setTextAppearance(getApplicationContext(), R.style.normalText);
                    resultRow.addView(txtType);

                    txtStart = new TextView(getApplicationContext());
                    txtStart.setText(annots.get(i).getStart());
                    txtStart.setTextAppearance(getApplicationContext(), R.style.normalText);
                    resultRow.addView(txtStart);

                    txtEnd = new TextView(getApplicationContext());
                    txtEnd.setText(annots.get(i).getEnd());
                    txtEnd.setTextAppearance(getApplicationContext(), R.style.normalText);
                    resultRow.addView(txtEnd);

                    txtFeats = new TextView(getApplicationContext());
                    txtFeats.setText(annots.get(i).getFeatures());
                    txtFeats.setTextAppearance(getApplicationContext(), R.style.normalText);
                    resultRow.addView(txtFeats);

                    tblResults.addView(resultRow);
                }
            } else if (current.mResultType.equals(SemanticServiceResult.BOUNDLESS_ANNOTATION)) {
                //TODO find an actual pipeline to test this with
            } else if (current.mResultType.equals(SemanticServiceResult.FILE)) {
                fileName = current.mFileUrl;
                fileName = fileName.substring(fileName.lastIndexOf("/") + 1);
                Log.d(Constants.TAG, fileName);
                getFileContentTask task = new getFileContentTask();
                task.execute(SemanticAssistantsActivity.serverURL);
            }
        }

        // reduce the number of allowed requests by one
        SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        String strReqNum = settings.getString("reqNum", "0");
        try {
            int intReqNum = Integer.parseInt(strReqNum);
            Editor editor = settings.edit();
            intReqNum--;
            editor.putString("reqNum", Integer.toString(intReqNum));
            boolean result = editor.commit();
            if (result) {
                Log.d(Constants.TAG, "Successfully reduced the reqNum");
            } else {
                Log.d(Constants.TAG, "Cannot reduced the reqNum");
            }
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
    } //else

}

From source file:reportsas.com.formulapp.Formulario.java

public LinearLayout obtenerLayout(LayoutInflater infla, Pregunta preg) {
    int id;/*  w  ww. j av  a 2s . c  o m*/
    int tipo_pregunta = preg.getTipoPregunta();
    LinearLayout pregunta;
    TextView textView;
    TextView textAyuda;
    switch (tipo_pregunta) {
    case 1:
        id = R.layout.pregunta_texto;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloPregunta);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        break;
    case 2:
        id = R.layout.pregunta_multitexto;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.mtxtTritulo);
        textAyuda = (TextView) pregunta.findViewById(R.id.mtxtAyuda);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());

        break;
    case 3:
        id = R.layout.pregunta_seleccion;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloSeleccion);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_seleccion);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        RadioGroup rg = (RadioGroup) pregunta.findViewById(R.id.opcionesUnica);
        ArrayList<OpcionForm> opciones = preg.getOpciones();
        final ArrayList<RadioButton> rb = new ArrayList<RadioButton>();

        for (int i = 0; i < opciones.size(); i++) {
            OpcionForm opcion = opciones.get(i);
            rb.add(new RadioButton(this));
            rg.addView(rb.get(i));
            rb.get(i).setText(opcion.getEtInicial());

        }
        final TextView respt = (TextView) pregunta.findViewById(R.id.respuestaGruop);
        rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                int radioButtonID = group.getCheckedRadioButtonId();
                RadioButton radioButton = (RadioButton) group.findViewById(radioButtonID);
                respt.setText(radioButton.getText());
            }
        });

        break;
    case 4:
        id = R.layout.pregunta_multiple;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloMultiple);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_mltiple);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        ArrayList<OpcionForm> opciones2 = preg.getOpciones();
        final EditText ediOtros = new EditText(this);
        ArrayList<CheckBox> cb = new ArrayList<CheckBox>();

        for (int i = 0; i < opciones2.size(); i++) {
            OpcionForm opcion = opciones2.get(i);
            cb.add(new CheckBox(this));
            pregunta.addView(cb.get(i));
            cb.get(i).setText(opcion.getEtInicial());
            if (opcion.getEditble().equals("S")) {

                ediOtros.setEnabled(false);
                ediOtros.setId(R.id.edtTexto);
                pregunta.addView(ediOtros);
                cb.get(i).setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        if (isChecked) {
                            ediOtros.setEnabled(true);
                        } else {
                            ediOtros.setText("");
                            ediOtros.setEnabled(false);
                        }
                    }
                });
            }

        }
        TextView spacio = new TextView(this);
        spacio.setText("        ");
        spacio.setVisibility(View.INVISIBLE);
        pregunta.addView(spacio);
        break;
    case 5:
        id = R.layout.pregunta_escala;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloEscala);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_escala);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());

        TextView etInicial = (TextView) pregunta.findViewById(R.id.etInicial);
        TextView etFinal = (TextView) pregunta.findViewById(R.id.etFinal);
        OpcionForm opci = preg.getOpciones().get(0);
        etInicial.setText(opci.getEtInicial());
        etFinal.setText(opci.getEtFinal());
        final TextView respEscala = (TextView) pregunta.findViewById(R.id.seleEscala);
        RatingBar rtBar = (RatingBar) pregunta.findViewById(R.id.escala);
        rtBar.setNumStars(Integer.parseInt(opci.getValores().get(0).getDescripcion()));
        rtBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
            @Override
            public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
                respEscala.setText("" + Math.round(rating));
            }
        });

        break;
    case 6:
        id = R.layout.pregunta_lista;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloLista);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_lista);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        ArrayList<OpcionForm> opciones3 = preg.getOpciones();
        //Creamos la lista
        LinkedList<ObjetoSpinner> opcn = new LinkedList<ObjetoSpinner>();
        //La poblamos con los ejemplos
        for (int i = 0; i < opciones3.size(); i++) {
            opcn.add(new ObjetoSpinner(opciones3.get(i).getIdOpcion(), opciones3.get(i).getEtInicial()));
        }

        //Creamos el adaptador*/
        Spinner listad = (Spinner) pregunta.findViewById(R.id.opcionesListado);
        ArrayAdapter<ObjetoSpinner> spinner_adapter = new ArrayAdapter<ObjetoSpinner>(this,
                android.R.layout.simple_spinner_item, opcn);
        //Aadimos el layout para el men y se lo damos al spinner
        spinner_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        listad.setAdapter(spinner_adapter);

        break;
    case 7:
        id = R.layout.pregunta_tabla;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloTabla);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_tabla);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        TableLayout tba = (TableLayout) pregunta.findViewById(R.id.tablaOpciones);
        ArrayList<OpcionForm> opciones4 = preg.getOpciones();
        ArrayList<RadioButton> radiosbotonoes = new ArrayList<RadioButton>();
        for (int i = 0; i < opciones4.size(); i++) {
            TableRow row = (TableRow) LayoutInflater.from(this).inflate(R.layout.row_pregunta_tabla, null);
            RadioGroup tg_valores = (RadioGroup) row.findViewById(R.id.valoresRow);

            final ArrayList<RadioButton> valoOpc = new ArrayList<RadioButton>();
            ArrayList<Valor> valoresT = opciones4.get(i).getValores();
            for (int k = 0; k < valoresT.size(); k++) {
                RadioButton rb_nuevo = new RadioButton(this);
                rb_nuevo.setText(valoresT.get(k).getDescripcion());
                tg_valores.addView(rb_nuevo);
                valoOpc.add(rb_nuevo);
            }

            ((TextView) row.findViewById(R.id.textoRow)).setText(opciones4.get(i).getEtInicial());
            tba.addView(row);
        }
        TextView espacio = new TextView(this);
        espacio.setText("        ");
        pregunta.addView(espacio);
        break;
    case 8:
        id = R.layout.pregunta_fecha;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloFecha);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_fecha);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());

        break;
    case 9:
        id = R.layout.pregunta_hora;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloHora);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_hora);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());

        break;
    default:
        id = R.layout.pregunta_multiple;
        pregunta = (LinearLayout) infla.inflate(id, null, false);

        textView = (TextView) pregunta.findViewById(R.id.TituloMultiple);
        textAyuda = (TextView) pregunta.findViewById(R.id.texto_ayuda_mltiple);
        textView.setText(preg.getOrden() + ". " + preg.getTitulo());
        textAyuda.setText(preg.getTxtAyuda());
        break;
    }

    return pregunta;
}

From source file:edu.pdx.its.portal.routelandia.ListStat.java

private void buildTable(int rows, int cols, ArrayList<TrafficStat> trafficStats, TableLayout tableLayout) {

    // outer for loop
    for (int i = -1; i < rows; i++) {

        TableRow row = new TableRow(this);
        row.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
                TableRow.LayoutParams.MATCH_PARENT));

        if (i == -1) {
            for (int j = 0; j < cols; j++) {

                TextView tv = new TextView(this);
                tv.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
                        TableRow.LayoutParams.MATCH_PARENT));
                tv.setBackgroundResource(R.drawable.cell_shape);
                tv.setPadding(40, 40, 40, 40);
                tv.setTextColor(Color.BLACK);
                if (j == 0) {
                    tv.setText("Time");
                } else if (j == 1) {
                    tv.setText("Speed");
                } else if (j == 2) {
                    tv.setText("Travel Time");
                } else {
                    tv.setText("Prediction Accuracy");
                }/* www . ja v  a  2s  .c o m*/
                row.addView(tv);
            }
        } else {
            // inner for loop
            for (int j = 0; j < cols; j++) {

                TextView tv = new TextView(this);
                tv.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,
                        TableRow.LayoutParams.MATCH_PARENT));
                tv.setBackgroundResource(R.drawable.cell_shape);
                tv.setPadding(40, 40, 40, 40);
                tv.setTextColor(Color.BLACK);
                if (j == 0) {
                    if (trafficStats.get(i).getMinutes() == 0) {

                        tv.setText(trafficStats.get(i).getHour() + ":" + trafficStats.get(i).getMinutes()
                                + trafficStats.get(i).getMinutes());

                    } else {
                        tv.setText(trafficStats.get(i).getHour() + ":" + trafficStats.get(i).getMinutes());
                    }
                } else if (j == 1) {
                    tv.setText(trafficStats.get(i).getSpeed() + " MPH");
                } else if (j == 2) {
                    tv.setText(trafficStats.get(i).getTravelTime() + " Min");
                } else {
                    tv.setText(trafficStats.get(i).getAccuracy() + "%");
                }

                row.addView(tv);

            }
        }

        tableLayout.addView(row);

    }
}

From source file:nl.openkvk.MainActivity.java

public void searchInKvK(View view) {
    TableLayout tl = (TableLayout) findViewById(R.id.tableOuter);
    tl.removeAllViews();/*from w  w w  . j a  va2 s.  c om*/
    EditText _naam = (EditText) findViewById(R.id.inpNaam);
    EditText _straat = (EditText) findViewById(R.id.inpStraat);
    EditText _postcode = (EditText) findViewById(R.id.inpPostcode);
    EditText _plaats = (EditText) findViewById(R.id.inpPlaats);
    EditText _hdlNaam = (EditText) findViewById(R.id.inpHandelsNaam);
    String naam = _naam.getText().toString().trim();
    String hdlNaam = _hdlNaam.getText().toString().trim();
    String straat = _straat.getText().toString().trim();
    String postcode = _postcode.getText().toString().trim().toUpperCase();
    if (postcode.indexOf(' ') > 0) {
        postcode = postcode.replace(" ", "");
    }
    String plaats = _plaats.getText().toString().trim();
    _naam.setText(naam);
    _hdlNaam.setText(hdlNaam);
    _straat.setText(straat);
    _postcode.setText(postcode);
    _plaats.setText(plaats);
    String sql = null;
    if (naam.length() > 0) {
        try {
            Integer kvk = Integer.valueOf(naam);
            sql = "/json/select * from kvk where kvks=" + kvk;
        } catch (Exception ignore) {
            sql = "/json/select * from kvk where bedrijfsnaam ilike '" + naam + "%'";
        }
        if (straat.length() > 0) {
            sql += " and adres ilike '" + straat + "%'";
        }
        if (plaats.length() > 0) {
            sql += " and plaats ilike '" + plaats + "%'";
        }
        if (postcode.length() > 0) {
            sql += " and postcode ilike '" + postcode + "%'";
        }
        sql += " LIMIT 1000;";
    } else if (hdlNaam.length() > 0) {
        sql = "/json/select * from kvk,kvk_handelsnamen where kvk.kvks=kvk_handelsnamen.kvks and handelsnaam ilike '"
                + hdlNaam + "%'";
        sql += " LIMIT 1000;";
    } else if (straat.length() > 0 && (plaats.length() > 0 || postcode.length() > 0)) {
        sql = "/json/select * from kvk where adres ilike '" + straat + "%'";
        if (plaats.length() > 0) {
            sql += " and plaats ilike '" + plaats + "%'";
        }
        if (postcode.length() > 0) {
            sql += " and postcode ilike '" + postcode + "%'";
        }
        sql += " LIMIT 1000;";
    } else if (postcode.length() == 6) {
        sql = "/json/select * from kvk where postcode='" + postcode + "'";
        sql += " LIMIT 1000;";
    }
    if (sql != null) {
        TextView tv = new TextView(this);
        tv.setText("Even geduld AUB...");
        TableRow tr = new TableRow(this);
        tr.addView(tv);
        tl.addView(tr);
        new Caller(handler, handler.holder, sql, 2).start();
    } else {
        {
            TextView tv = new TextView(this);
            tv.setText("Ongeldige invoer.");
            TableRow tr = new TableRow(this);
            tr.addView(tv);
            tl.addView(tr);
        }
        {
            TextView tv = new TextView(this);
            tv.setText("Geef een (gedeelte van) een bedrijfsnaam in. Of geef het KvK nummer.");
            tv.setSingleLine(false);
            TableRow tr = new TableRow(this);
            tr.addView(tv);
            tl.addView(tr);
        }
        {
            TextView tv = new TextView(this);
            tv.setText("Geef eventueel ook (het begin van) een straat, postcode en/of plaatsnaam in.");
            tv.setSingleLine(false);
            TableRow tr = new TableRow(this);
            tr.addView(tv);
            tl.addView(tr);
        }
        {
            TextView tv = new TextView(this);
            tv.setText("Of geef een straat (mag met huisnummer) en een plaats en/of een postcode in.");
            tv.setSingleLine(false);
            TableRow tr = new TableRow(this);
            tr.addView(tv);
            tl.addView(tr);
        }
        {
            TextView tv = new TextView(this);
            tv.setText("Of geef alleen een volledige postcode in.");
            tv.setSingleLine(false);
            TableRow tr = new TableRow(this);
            tr.addView(tv);
            tl.addView(tr);
        }
    }
}