3 Replies - 2005 Views - Last Post: 18 September 2012 - 06:22 PM

#1 ho-ho  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 69
  • Joined: 04-May 09

Graphical Layout of Main Activity is not being displayed in emulator

Posted 18 September 2012 - 11:57 AM

Hi,
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


Is This A Good Question/Topic? 0
  • +

Replies To: Graphical Layout of Main Activity is not being displayed in emulator

#2 H3R3T1C  Icon User is offline

  • Android Expert
  • member icon

Reputation: 276
  • View blog
  • Posts: 757
  • Joined: 30-March 07

Re: Graphical Layout of Main Activity is not being displayed in emulator

Posted 18 September 2012 - 01:03 PM

Are you getting any errors in logcat?
Was This Post Helpful? 0
  • +
  • -

#3 ho-ho  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 69
  • Joined: 04-May 09

Re: Graphical Layout of Main Activity is not being displayed in emulator

Posted 18 September 2012 - 05:30 PM

This is what i am getting in logcat
[2012-09-18 19:22:09 - Game] Android Launch!
[2012-09-18 19:22:09 - Game] adb is running normally.
[2012-09-18 19:22:09 - Game] Performing android.software.game.MainActivity activity launch
[2012-09-18 19:22:09 - Game] Automatic Target Mode: launching new emulator with compatible AVD 'CoolAVD'
[2012-09-18 19:22:09 - Game] Launching a new emulator with Virtual Device 'CoolAVD'
[2012-09-18 19:22:10 - Game] New emulator found: emulator-5554
[2012-09-18 19:22:10 - Game] Waiting for HOME ('android.process.acore') to be launched...
[2012-09-18 19:23:18 - Game] HOME is up on device 'emulator-5554'
[2012-09-18 19:23:18 - Game] Uploading Game.apk onto device 'emulator-5554'
[2012-09-18 19:23:24 - Game] Failed to install Game.apk on device 'emulator-5554': timeout
[2012-09-18 19:23:24 - Game] Launch canceled!

It's not being able to install .apk file to emulator.
How can i resolve this and be able to run my app.

This post has been edited by ho-ho: 18 September 2012 - 05:54 PM

Was This Post Helpful? 0
  • +
  • -

#4 ho-ho  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 69
  • Joined: 04-May 09

Re: Graphical Layout of Main Activity is not being displayed in emulator

Posted 18 September 2012 - 06:22 PM

Finally, resolved it.APK file was not installing properly in the emulator.So this is what I did,
Right click on your Project, choose properties, choose "Resource" (first option)
Under "Text file encoding" choose Other->UTF-8
Press the "Apply" Button and then Ok.
Than project-> clean and you can run the project.

This post has been edited by ho-ho: 18 September 2012 - 06:23 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1