Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Android Development

  1. #1
    Member
    Join Date
    Jun 2011
    Posts
    182
    My Mood
    Where
    Thanks
    15
    Thanked 8 Times in 8 Posts

    Default Android Development

    Ok... I am feeling like the Android API makes things way harder than they need to be (in some cases). For instance, can someone please tell me how to make a button? I can't figure out how to do it...

    I've tried this code but Eclipse says it can't find the variable 'id' in R.java. And, I don't understand how to instantiate a new button using Contexts. Help?

    public class AppLauncher extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            Button b = (Button)findViewById(R.id.button);
        }
    }

    Note: Using this.findViewById doesn't work either.


  2. #2
    Member
    Join Date
    Mar 2011
    Posts
    32
    My Mood
    Worried
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Android Development

    Exactly, some time I'm also bit confuse ..

    Quote Originally Posted by bgroenks96 View Post
    Ok... I am feeling like the Android API makes things way harder than they need to be (in some cases). For instance, can someone please tell me how to make a button? I can't figure out how to do it...

    I've tried this code but Eclipse says it can't find the variable 'id' in R.java. And, I don't understand how to instantiate a new button using Contexts. Help?

    public class AppLauncher extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            Button b = (Button)findViewById(R.id.button);
        }
    }

    Note: Using this.findViewById doesn't work either.

  3. #3
    Junior Member
    Join Date
    Aug 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Android Development

    First make button in XML and give ID to then then Save it
    then make class of java
    use this code
    Last edited by jps; August 30th, 2013 at 10:02 PM. Reason: spoonfeeding

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Android Development

    @Arvind6446 Please read The problem with spoonfeeding

Similar Threads

  1. Starting Android Application Development
    By MikeSki3 in forum Android Development
    Replies: 8
    Last Post: May 3rd, 2013, 07:54 AM
  2. What is the best SDK for creating new Android applications?
    By p0oint in forum Android Development
    Replies: 7
    Last Post: May 2nd, 2013, 02:02 PM
  3. How to use Android in (Eclipse || NetBeans)
    By benglish in forum Android Development
    Replies: 2
    Last Post: October 21st, 2011, 06:28 AM
  4. how to add adt(android plugin) to eclipse from zip file ???
    By mahdi in forum Android Development
    Replies: 2
    Last Post: July 9th, 2011, 02:32 PM
  5. PDE(plugins development environment)
    By swedenkhan in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 26th, 2011, 07:28 AM