Reputation: 1470
Im a newbie to android and with the help of some experts i write some code for displaying texts tableview in android.
Here is compiling without any errors but the app is not launching and the message "Unfortunately stopped working" error is showing.
HellotableActivity.java
import android.app.Activity;
import android.os.Bundle;
public class HelloTableLayoutActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:stretchColumns="1" >
<TableRow>
<TextView
android:layout_column="1"
android:text="@string/Open..."
android:padding="3dip" />
<TextView
android:text="@string/sujiO"
android:gravity="right"
android:padding="3dip" />
</TableRow>
<TableRow>
<TextView
android:layout_column="1"
android:text="@string/Save..."
android:padding="3dip" />
<TextView
android:text="@string/CtrlS"
android:gravity="right"
android:padding="3dip" />
</TableRow>
</LinearLayout>
strings.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, HelloTableLayoutActivity!</string>
<string name="app_name">HelloTableLayout</string>
<string name="Open...">HelloTableLayout</string>
<string name="sujiO">HelloTableLayout</string>
<string name="Save...">HelloTableLayout</string>
<string name="CtrlS">HelloTableLayout</string>
</resources>
Can anyone please help me with where im going wrong in this case.Thanks in advance.
Upvotes: 0
Views: 247
Reputation: 3422
TableRow
and TableView
don't work in LinearLayout
, use TableLayout
instead.
See the Table Layout example, which demonstrates very well how to use a TableLayout
.
By the way, you cannot use dots in string names. How would you refer them in Java? I think standard is lowercase separated with underscores. (Dev Guide Reference)
Upvotes: 1