I just started working with android and I have put two editText and a button. While running the app. on emulator nothing is being displayed, no controls.If someone could help in figuring out what am I missing here.
Below is the code for main activity. I only have a single activity right now. The title for the app should display as "Game" instead it's appearing as Main Activity. I have already changed in the strings.xml to "Game" but I don't know where it's picking the title as Main Activity.
public class MainActivity extends Activity {
String appInput;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final EditText input = (EditText)findViewById(R.id.myedit);
final EditText display = (EditText)findViewById(R.id.mynewedit);
Button button = (Button)findViewById(R.id.buttonsend);
button.setonclickListener(new View.onclickListener() {
public void onclick(View v) {
appInput = input.getText().toString();
display.setText(appInput);
}
}) ;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
here is the manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.software.game"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" android:debuggable="true">
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
below is the graphical layout for activity main
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
<EditText
android:id="@+id/myedit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/enteryourname"
android:inputType="text"
android:visible="true"/>
<EditText
android:id="@+id/mynewedit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/myedit"
android:layout_marginTop="18dp"
android:ems="10"
android:inputType="text"
android:visible="true"/>
<Button
android:id="@+id/buttonsend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="22dp"
android:text="@string/showname"
android:visible="true"/>
</RelativeLayout>
This post has been edited by H3R3T1C: 18 September 2012 - 12:45 PM
Reason for edit:: added code tags

New Topic/Question
Reply



MultiQuote




|