i have created two buttons and a textbox. the textbox shows the text that i referenced but the buttons don’t show the text as referenced. Instead they show “button”. Also when i run the application on my emulator then the application stops. Please Help!
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/txtDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/Disp"
tools:context=".myMain"
android:textSize= "45dp"
/>
<button
android:id="@+id/bAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/hello_world"
android:textSize="45dp" />
<button
android:layout_gravity="center"
android:layout_width = "wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
android:id="@+id/bSub"
android:textSize = "45dp"/>
</LinearLayout>
Here is the Strings.xml
<resources>
<string name="app_name">Basictut</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_my_main">myMain</string>
<string name="Disp">Your Total Is 0</string>
<string name="add">Add one</string>
<string name="sub">Subtract one</string>
</resources>
Java Code is:
package com.example.basictut;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
public class myMain extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_my_main, menu);
return true;
}
}
The xml is case sensitive, I think you should write
Buttoninstead ofbutton.