Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to getText from edittext contained in tablerow
    text
    copied!<p>Hi i use TableLyout to display data from my database (baza_kosztorys),i contain date from three columns (kosztorys_id, kosztorys_nazwa, inwestor) in tablerow (wiersz), i added button(przycisk) also and i put kosztorys_id as setText. Later i can gettext from button when i clicked on it(it works good), but i'd like to clik tablerow and gettext from edittext, without using button.</p> <p>And it's a problem because gettext(kosztorys_id) from edittext it's not working the same as button, so how i can gettext from edittext when i click tablerow ??</p> <p>my code.</p> <pre><code>package com.kosztorys; import android.app.Activity; public class NowePomieszczenie extends Activity implements OnClickListener{ String Timie, Tnazwisko, Tmail; SQLiteDatabase db; TextView textview1,textview2,textview3, textview4, textview5; Button przycisk; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.nowe_pomieszczenie); db=openOrCreateDatabase("baza_kosztorys", MODE_PRIVATE, null); } public void pokazdane(View v) { final Cursor c=db.rawQuery("SELECT * from kosztorys", null); int count= c.getCount(); c.moveToFirst(); //definicja wygladu final TableLayout wyglad = new TableLayout(getApplicationContext()); wyglad.setVerticalScrollBarEnabled(true); //definicja wiersza TableRow wiersz = new TableRow(getApplicationContext()); //dodanie napisu id nad kolumna id TextView textview = new TextView(getApplicationContext()); textview.setText("DOSTĘPNE KOSZTORYSY"); textview.setTextColor(Color.BLUE); textview.setTypeface(null, Typeface.BOLD); textview.setPadding(20, 20, 20, 20); wiersz.addView(textview); wyglad.addView(wiersz); for(Integer j=0; j&lt;count; j++) { wiersz = new TableRow(getApplicationContext()); wiersz.setClickable(true); textview = new TextView(getApplicationContext()); textview.setText(c.getString(c.getColumnIndex("kosztorys_id"))); textview2 = new TextView(getApplicationContext()); textview2.setText(c.getString(c.getColumnIndex("kosztorys_nazwa"))); textview3 = new TextView(getApplicationContext()); textview3.setText(c.getString(c.getColumnIndex("inwestor"))); przycisk = new Button(getApplicationContext()); przycisk.setText(c.getString(c.getColumnIndex("kosztorys_id"))); wiersz.setTag(c.getString(c.getColumnIndex("kosztorys_id"))); przycisk.setOnClickListener(new OnClickListener(){ @Override public void onClick(View v) { //v.setBackgroundColor(Color.GRAY); Button przycisk = (Button)v; String buttonText = przycisk.getText().toString(); setContentView(R.layout.nowe_pomieszczenie); // String buttonText2 = c.getString(c.getColumnIndex("kosztorys_id")); Toast.makeText(NowePomieszczenie.this, "wybrales kosztorys nr:"+buttonText, Toast.LENGTH_SHORT).show(); } }); wiersz.setOnClickListener(new OnClickListener() { public void onClick(View v) { v.setBackgroundColor(Color.GRAY); } }); //textview.setPadding(20, 20, 20, 20); textview2.setPadding(20, 20, 20, 20); textview3.setPadding(20, 20, 20, 20); przycisk.setPadding(20, 20, 20, 20); wiersz.addView(textview); wiersz.addView(textview2); wiersz.addView(textview3); wiersz.addView(przycisk); wyglad.addView(wiersz); c.moveToNext(); } setContentView(wyglad); db.close(); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload