Here, I have given android example of table layout in which we can hide, show or stretch any column. Open your main xml file and paste below code
</LinearLayout>
Now open your java file and paste below code
Now run this android table layout example on your device and test.
<LinearLayout xmlns:android="http://schemas. android.com/apk/res/android"
android:layout_width="fill_ parent"
android:layout_height="fill_ parent"
android:orientation="vertical"
>
<TableLayout
android:id="@+id/tl"
android:layout_width="match_ parent"
android:layout_height="wrap_ content"
android:stretchColumns="0,1,2" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_ content"
android:layout_height="wrap_ content"
>
<Button
android:id="@+id/button1"
android:layout_width="wrap_ content"
android:layout_height="wrap_ content"
android:text="B1"
android:onClick="gayab"/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_ content"
android:layout_height="wrap_ content"
android:text="B2"
/>
<Button
android:id="@+id/button3"
android:layout_width="wrap_ content"
android:layout_height="wrap_ content"
android:text="B3"
/>
</TableRow>
<TableRow
android:id="@+id/tableRow1"
android:layout_width="wrap_ content"
android:layout_height="wrap_ content"
>
<Button
android:id="@+id/button5"
android:layout_width="wrap_ content"
android:layout_height="wrap_ content"
android:text="B1"
/>
<Button
android:id="@+id/button6"
android:layout_width="wrap_ content"
android:layout_height="wrap_ content"
android:text="B2"
/>
<Button
android:id="@+id/button7"
android:layout_width="wrap_ content"
android:layout_height="wrap_ content"
android:text="B3"
/>
</TableRow>
</TableLayout>
<Button
android:id="@+id/button4"
android:layout_width="wrap_ content"
android:layout_height="wrap_ content"
android:text="Gayab"
android:onClick="gayab"
/>
Now open your java file and paste below code
package selcom.testlay;//your package name
import
android.os.Bundle;
import
android.app.Activity;
import android.view.Menu;
import
android.view.View;
import
android.widget.Button;
import
android.widget.TableLayout;
public class MainActivity extends Activity {
TableLayout ll;
Button b4;
@Override
protected void onCreate(Bundle
savedInstanceState) {
super.onCreate( savedInstanceState);
setContentView(R.layout.activi ty_main);
ll=(TableLayout)findViewById( R.id.tl);
b4=(Button)findViewById(R.id.b utton4);
}
public void gayab(View v)
{
//visible and invisible collumn
ll.setColumnCollapsed(0,
!ll.isColumnCollapsed(0));
if(ll.isColumnCollapsed(0))
{
b4.setText("show");
}
else
{
b4.setText("Hide");
}
}
}
Now run this android table layout example on your device and test.
I want to share table layout throw sms so how to get table layout and share it ?
ReplyDeletethanks
You must know about server connection and then give permission handler in android manifest and make an Service Handler use post method to send value and then use server script to receive data, which is in localhost wamp/xamp. I think it is very difficult for beginers but you can try these steps and get code from any source like stackoverflow or androidhive.
ReplyDelete