WEB Java People... why isn't my button showing up (code & screenshot)

Discussion in 'OT Technology' started by brds, Nov 18, 2009.

  1. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,650
    Likes Received:
    15
    Location:
    Atlanta
    I'm trying to learn how to program for android. I've followed a couple tutorials but can't get a button to show up.

    XML CODE:
    Code:
       <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="top"
        >
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/welcomeMessage"
        />
       
      <Button
          android:id="@+id/homeButton"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Home"
      />
    </LinearLayout>
    
    Java Code:
    Code:
    package DroidTones.homeScreen;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    public class droidTonesHomeScreen extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
        }
    }
    Screenshot of android emulator running the app:
    [​IMG]
     
  2. SIGirl

    SIGirl Super Duper Moderator Super Moderator

    Joined:
    Nov 1, 2001
    Messages:
    22,681
    Likes Received:
    1,381
    Location:
    Austin, TX
    Narc likes this.
  3. Pepsi1975

    Pepsi1975 Mod of the Year

    Joined:
    Jan 6, 2005
    Messages:
    47,590
    Likes Received:
    1
    Location:
    Detroit
    oh shit I did not know sigirl knew this shit

    :bowdown:
     
  4. SIGirl

    SIGirl Super Duper Moderator Super Moderator

    Joined:
    Nov 1, 2001
    Messages:
    22,681
    Likes Received:
    1,381
    Location:
    Austin, TX
    So here's one in the app I am making...

    in the layout:
    <Button android:id="@+id/confirm" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:layout_marginLeft="40px"
    android:text="Confirm" />
    <Button android:id="@+id/cancel" android:layout_width="wrap_content"
    android:layout_height="wrap_content" android:text="Cancel" />

    in the code:
    Button conf = (Button)findViewById(R.id.confirm);
    Button decline = (Button)findViewById(R.id.cancel);
    decline.setOnClickListener(getConfirmCancelListener());
    conf.setOnClickListener(getConfirmOkListener());

    //listener for the confirmation overlay
    private View.OnClickListener getConfirmCancelListener(){
    return new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    LinearLayout lay = (LinearLayout)findViewById(R.id.confirmation);
    lay.setVisibility(4);
    showStuff();
    }
    };
    }
     
    Narc likes this.
  5. SIGirl

    SIGirl Super Duper Moderator Super Moderator

    Joined:
    Nov 1, 2001
    Messages:
    22,681
    Likes Received:
    1,381
    Location:
    Austin, TX
    Shhh it's a secret ;)
     
    Narc likes this.
  6. Ricky

    Ricky █▄ █▄█ █▄ ▀█▄

    Joined:
    Jun 17, 2005
    Messages:
    38,767
    Likes Received:
    6
    fucking java.

    so glad i dont have to take that shit again
     
  7. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,650
    Likes Received:
    15
    Location:
    Atlanta
  8. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,650
    Likes Received:
    15
    Location:
    Atlanta
    Becoming necessary for a truly well rounded web developer :wtc:
     
  9. SIGirl

    SIGirl Super Duper Moderator Super Moderator

    Joined:
    Nov 1, 2001
    Messages:
    22,681
    Likes Received:
    1,381
    Location:
    Austin, TX
    In your layout when you click on layout, not the xml but the design, do you see a button? You should...
     
    Narc likes this.
  10. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,650
    Likes Received:
    15
    Location:
    Atlanta
    I dunno how to view in layout... this is what my screen looks like:

    [​IMG]
     
  11. SIGirl

    SIGirl Super Duper Moderator Super Moderator

    Joined:
    Nov 1, 2001
    Messages:
    22,681
    Likes Received:
    1,381
    Location:
    Austin, TX
    Weird, mine actually shows a frame with my buttons on it. Try going by the tutorial I sent you, that's what I used for mine. I made a new layout xml just for my buttons because I only want them to show when the user gets to a certain screen...sorry I didn't help much.
     
    Narc likes this.
  12. Pepsi1975

    Pepsi1975 Mod of the Year

    Joined:
    Jan 6, 2005
    Messages:
    47,590
    Likes Received:
    1
    Location:
    Detroit
    :bowdown:
     
  13. Phasm

    Phasm OT Supporter

    Joined:
    Sep 20, 2005
    Messages:
    9,680
    Likes Received:
    0
    Location:
    Michigan
    I fucking hate java :o my least favorite class this semester
     
  14. brds

    brds OT Supporter

    Joined:
    Jun 26, 2006
    Messages:
    17,650
    Likes Received:
    15
    Location:
    Atlanta

    Last time I loaded up eclipse that view was there... anybody know how to get it back?
     
  15. Swerve

    Swerve OT Supporter

    Joined:
    Feb 20, 2005
    Messages:
    3,179
    Likes Received:
    3
    Not a fan of Java either, but like was mentioned, I think it's gonna be a 'have to know' in the future.
     
  16. SIGirl

    SIGirl Super Duper Moderator Super Moderator

    Joined:
    Nov 1, 2001
    Messages:
    22,681
    Likes Received:
    1,381
    Location:
    Austin, TX
    :werd: I'm trying to be well rounded. I had one semester where I had Algorithms in C++, Methodologies in XNA and advanced ASP.net then the next semester Java EE and Android. I feel like I'm going to essssplode. :noes:
     
    Narc likes this.
  17. Major Tom

    Major Tom OT Supporter

    Joined:
    Mar 10, 2003
    Messages:
    5,683
    Likes Received:
    0
    Location:
    England
    Java fucking blows.
     

Share This Page