1. Download our Official Android App: Forums for Android!

Apps First Android app - no go so far

Discussion in 'Android Development' started by clayshannon, Jul 29, 2011.

  1. clayshannon

    clayshannon Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Jul 29, 2011

    Jul 29, 2011
    4
    0
    5
    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 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.bobas.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:

    Code (Text):
    1.  
    2. package com.bobas;
    3.  
    4. import android.app.Activity;
    5. import android.os.Bundle;
    6. import android.widget.TextView;
    7.  
    8. public class YeauxDudimusActivity extends Activity {
    9.     /** Called when the activity is first created. */
    10.  @Override
    11.  public void onCreate(Bundle savedInstanceState) {      
    12.   super.onCreate(savedInstanceState);      
    13.   TextView tv = new TextView(this);        
    14.   tv.setText("Yeaux, Dudimus");        
    15.   setContentView(tv);        
    16.   setContentView(R.layout.main);            
    17.   }
    18. }
    19.  
     

    Advertisement

  2. dimiter

    dimiter Newbie
    Rank:
    None
    Points:
    16
    Posts:
    27
    Joined:
    Jul 27, 2011

    Jul 27, 2011
    27
    3
    16
    Moscow
    Press MENU buttom in emulator.
    Also there is error in code: when called SetContentView, user intenface will rewrite.
     
  3. clayshannon

    clayshannon Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Jul 29, 2011

    Jul 29, 2011
    4
    0
    5
    I see no button that says "Menu" - does it have a certain icon?

    And: which SetContentView() should I comment out - does it matter?
     
  4. clayshannon

    clayshannon Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Jul 29, 2011

    Jul 29, 2011
    4
    0
    5
    OK, now I see the "Menu" button - I was using a 3.2 ADV, and that wasn't working well. When I switched to using one for 2.1 that I set up, I now see it. However, clicking "menu" does not show me an icon for my app. And clicking the "drawer" does bring up a plethora of apps, but none of them are the one I wrote... ???
     
  5. QuackWare

    QuackWare Newbie
    Rank:
    None
    Points:
    16
    Posts:
    22
    Joined:
    Jul 14, 2010

    You probably want to comment out the textview setContentView lines to start out. Also have you tried running your program on different SDK versions and using different emulators? Do any errors show up in logcat that you can show us?
     
  6. dimiter

    dimiter Newbie
    Rank:
    None
    Points:
    16
    Posts:
    27
    Joined:
    Jul 27, 2011

    Jul 27, 2011
    27
    3
    16
    Moscow
    Try launch emulator, press MENU button and run application. Wait a few seconds and you will see you app launch.
    Delete:
    Code (Text):
    1.  
    2. TextView tv = new TextView(this);         tv.setText("Yeaux, Dudimus");         setContentView(tv);
    3.  
    And add this after super.onCreate...:
    tv=(TextView) findViewById(R.id.text);
    Also you should add TextView Widget in main.xml and define his id as text and define it as class field after defined-class line:
    private TextView tv
     
  7. clayshannon

    clayshannon Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Jul 29, 2011

    Jul 29, 2011
    4
    0
    5
    Thanks for those suggestions; I'll try them when I can, but at the moment I can't even run Eclipse. The Emulator froze so solidly that I had to use Ctrl+Alt+Delete to try to shut it down, and when that didn't work, I performed a manual reboot. Since then, the external drive on which all of my Java and Android stuff is installed is no longer accessible, and even Explorer not only won't show my that external drive, it won't show me ANYTHING - and Control Panel | Add and Remove Programs never populates its list.
     

Share This Page

Loading...