Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By bal00

Thread: One step forward, and 0.9 steps back

  1. #1
    blackbird is offline Senior Member
    Join Date
    Jul 2011
    Posts
    100
    Rep Power
    0

    Default One step forward, and 0.9 steps back

    I'm trying to run a very simple (my first) Android app in an emulator I've set up, but my app doesn't display within the emulator. I'm expecting to see (code below) a TextView with some Text assigned to it.

    All I see is a black "honeycomb" background in the emulator (which looks like a "DOS box" or Command prompt) with the time (5 hours in the future), date, and "Charging (50%)"

    I'm using an AVD set up to use a version 3.2 emulator. I've got that (Andorid 3.2 SDK) and Java 7 installed.

    Here is what is contained in my Eclipse tabs:

    Console:

    [2011-07-29 02:16:39 - YeauxDudimus] ------------------------------
    [2011-07-29 02:16:39 - YeauxDudimus] Android Launch!
    [2011-07-29 02:16:39 - YeauxDudimus] adb is running normally.
    [2011-07-29 02:16:39 - YeauxDudimus] Performing com.bomb.YeauxDudimusActivity activity launch

    Error Log:

    While loading class "com.android.ide.eclipse.adt.ToolsLocator", thread "Thread[Worker-2,5,main]" timed out waiting (5016ms) for thread "Thread

    Problems:

    None

    Code:

    Java Code:
    package com.bomb;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.TextView;
    
    public class YeauxDudimusActivity extends Activity {
        /** Called when the activity is first created. */    
    @Override    
    public void onCreate(Bundle savedInstanceState) {        
      super.onCreate(savedInstanceState);        
      TextView tv = new TextView(this);        
      tv.setText("Yeaux, Dudimus");        
      setContentView(tv);        
      setContentView(R.layout.main);            
      }
    }

  2. #2
    bal00 is offline Member
    Join Date
    Aug 2011
    Posts
    2
    Rep Power
    0

    Default

    Did you unlock the screen of the virtual device?

    You will also want to change your code. Right now you're setting the ContentView to tv, and then you're telling the activity to display the (presumable empty) main.xml instead. You should probably acquaint yourself with Android's XML-based UIs too, because in my experience trying to set up the UI in code doesn't get your very far in Android.

    I would use something like this:

    Java Code:
    public void onCreate(Bundle savedInstanceState) {        
      super.onCreate(savedInstanceState);        
      setContentView(R.layout.main);            
    
      TextView tv = (TextView) findViewById(R.id.mytextview);        
      tv.setText("Yeaux, Dudimus");        
    
      }
    And then edit res/layout/main.xml:

    Java Code:
    <?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">
    
    	<TextView android:id="@+id/mytextview"
    		android:text="" android:textColor="#000000" />
    
    </LinearLayout>
    And if you want to add more stuff to your UI, simply add it to the XML and grab it using findViewById().
    blackbird likes this.

  3. #3
    blackbird is offline Senior Member
    Join Date
    Jul 2011
    Posts
    100
    Rep Power
    0

    Default

    Thanks, Balloo!

    BTW, you're one of my favorite characters from The Jungle Book.

    That makes me wonder...was Shere Khan related to Tigger??? They seem so different...

Similar Threads

  1. Step-by-Step Billing system in Web Services
    By oneofthelions in forum Web Frameworks
    Replies: 2
    Last Post: 12-18-2009, 10:28 AM
  2. EJB3 Message driven beans step-by-step guide
    By nix123456 in forum Enterprise JavaBeans (EJB)
    Replies: 3
    Last Post: 09-28-2009, 01:29 PM
  3. I need a back and forward code
    By Jaymz in forum New To Java
    Replies: 9
    Last Post: 10-12-2008, 11:50 PM
  4. Back-Forward Simulation using stacks(java)
    By MarKus in forum New To Java
    Replies: 3
    Last Post: 09-10-2008, 01:47 PM
  5. Step-by-Step Tutorial: Achieve RAD with Seam+Eclipse+Tomcat
    By Techieexchange in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 11-13-2007, 07:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •