Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do you attach a TableLayout to a button when working with Android?
    text
    copied!<p>I simply want to know how to call/attach/send a table with text to a button. I can get ListView to work fine but I don't know the "idea" behind a TableLayout. All I want it to do is: when the button is pressed it should go to the table and display the text. I'm not looking for anything fancy just simply display the text in a table when the button is pressed. I have a button (named buttonInfo.java)set up on a menu like this:</p> <pre><code>Button btnInfo = (Button) findViewById(R.id.buttonInfo); btnInfo.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub startActivity(new Intent("com.crazyj.peopleinfo.BUTTONINFO")); } }); </code></pre> <p>Here is the table (named infotable.xml)with the text:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="1"&gt; &lt;TableRow&gt; &lt;TextView android:text="Name" android:padding="3dip" /&gt; &lt;TextView android:text="John" android:gravity="right" android:padding="3dip" /&gt; &lt;/TableRow&gt; &lt;TableRow&gt; &lt;TextView android:text="Number" android:padding="3dip" /&gt; &lt;/TableRow&gt; &lt;TableRow&gt; &lt;TextView android:text="Age" android:padding="3dip" /&gt; &lt;TextView android:text="32" android:gravity="right" android:padding="3dip" /&gt; &lt;/TableRow&gt; &lt;/TableLayout&gt; </code></pre> <p>buttonInfo class:</p> <pre><code>package com.crazyj.peopleinfo; import android.content.Context; import android.widget.TableLayout; public class buttonInfo extends TableLayout{ public buttonInfo(Context context) { super(context); // TODO Auto-generated constructor stub } } </code></pre> <p>If anyone can answer this please explain what it means! I'm here to learn, not just get answers. And thanks!</p>
 

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