Android Forums

Go Back   These FORUMS ARE DISABLED!! OUR NEW FORUMS ARE AT http://androidforum.com/ > Android Coders > Android Development, Answers, Tutorials, and Code Snippets
Connect with Facebook

Click Here To Register!
 
 
LinkBack Thread Tools Display Modes
Old 06-25-2009, 03:46 AM   #1
Junior Member
 
Join Date: Jun 2009
Posts: 2
Friends: 0
View riceri's Profile   View riceri's Photo Album   View riceri's Blog   View Social Groups
Hi!

I am trying make a little tool for my self to learn programming for the android.

This is the goal:
First layout shall be a ListView when selected one thing in that a new layout with info shall be shown. Now from this view i want a menu where i can change view to MapView or status view, and then back.


The problem is that i got no clue how to make this. I made total 4 view, one for the listview, one for the info, one for the map and one for the status. How do i bind all buttons and stuff, i get a error if i try to bind a button that isn't shown atm.

I hope you understand my problem. It would be nice with just some sample on how to switch between diffrent layouts and stuff like that.
riceri is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 07-10-2009, 11:44 PM   #2
Junior Member
 
Join Date: Jul 2009
Posts: 6
Friends: 0
View Radzell's Profile   View Radzell's Photo Album   View Radzell's Blog   View Social Groups
I'm learning how to program to and i am looking for dev team to learn with. Maybe we can make the app together so both of us can get better
Radzell is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 07-12-2009, 10:50 AM   #3
Junior Member
 
Join Date: Jun 2009
Posts: 2
Friends: 0
View riceri's Profile   View riceri's Photo Album   View riceri's Blog   View Social Groups
Sorry, forgot this topic.
I have found the book Hello, Android.
Now that i have read that i understand that i was thinking wrong and thats why i had problems.
riceri is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 09-16-2009, 10:32 PM   #4
Junior Member
 
Join Date: Sep 2009
Location: India
Posts: 3
Friends: 0
View unnikrisb's Profile   View unnikrisb's Photo Album   View unnikrisb's Blog   View Social Groups
Does anyone share basic codes on Android.? especially using MediaPlayer class
unnikrisb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 11-28-2011, 01:26 AM   #5
New Member
 
Join Date: Nov 2011
Posts: 4
Friends: 0
View Rapidstart's Profile   View Rapidstart's Photo Album   View Rapidstart's Blog   View Social Groups
We Offer training courses on Android take a look whether does it benefit you.

www.rapidstart.com.sg

Last edited by Rapidstart; 11-29-2011 at 06:36 PM..
Rapidstart is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 11-28-2011, 02:03 PM   #6
Member
 
Join Date: May 2011
Posts: 95
Friends: 0
View Phyll's Profile   View Phyll's Photo Album   View Phyll's Blog   View Social Groups
Hi All,

There's lots of people willing to share their code and experience right here. Everybody had to start some place.

Here's some code for doing something with a couple of buttons:

Code:
    private static int SOUND_1 = 1;

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        initSounds();
        Button play = (Button)findViewById(R.id.button_play);
        play.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                playSound(SOUND_1);
                }
            });
        Button secondActivity = (Button)findViewById(R.id.button_secondactivity);
        secondActivity.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
               Intent i = new Intent(YourActivity.this, Second.class);
                startActivityForResult(i, ACTIVITY_ID);
                }
            });        
        }  

Here's a layout for them:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <Button
        android:id="@+id/button_play"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Play"
        />
    <Button
        android:id="@+id/button_secondactivity"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Second Activity"
        />
</LinearLayout>
Does that help any?

Phyll

PS

I probably shouldn't do it because its just opening up Pandora's box but here's something that might help you learn by example.

Go to betterpaving.com/stuff/ and download the Android Code Writer application you'll find there.

This application allows you to write an outline of your Android app in pcode. Then it converts it into Java code and xml files. Finally, it can export those files directly into a project in Eclipse.

For example, if you wanted to create two activities and have one able to start the other and return results from it, you could just write an outline like this:

Code:
Package com.bandpsoftware
Application App9

Activity App9 Activity
    Intent MAIN LAUNCHER
    View Button Second
    End Activity

Activity Second Activity
    View Button Done
    End Activity

Handoff App9 Second
Uses Sdk 7
This will give you an application named App9 with a package of com.bandpsoftware.app9. You can make them anything you want. The app would have two activities. Each has a button to allow switching to the other. Boilerplate code to make the handoff to and from the second activity is accomplished by the Handoff statement. Finally it will require a minimum of level 7.

It makes a .java file and a layout xml for each activity. It makes a strings.xml file and puts strings there if you declare them and some names and labels. It also makes the manifest file and puts all of them in the proper folders when its exported.

It is not meant to be a production application so it might break once and a while but all in all I find it very useful for making apps in minutes. When you get it working, click the help button so you can get an idea what it can do. You can add to the help file by just typing and clicking the Save button. There are a number of statements that cause code to be written for custom forms, menus and custom menus, taking pictures, creating a drawing surface, using preferences, alerts, timers, threads, images, icons, sounds, text file read and write, phone dialing, slider widget, configuration changes, services and alarms to name a few.

I add to it frequently so you should check back now and then to see if its version has changed.

Here's what the App9 main activity example .java code looks like:

Code:
package com.bandpsoftware.app9;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.content.Intent;

public class App9 extends Activity {

    private static final int SHOW_NAME = 1;

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        Button second = (Button)findViewById(R.id.button_second);
        second.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                //TODO: Button Function
                }
            });
        }

    //Add this to a button handler, menu item, etc.
    //Intent i = new Intent(App9.this, Second.class);
    //startActivityForResult(i, SHOW_NAME);

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == SHOW_NAME)
            if (resultCode == Activity.RESULT_OK) {

                //TODO: Do something here with it

                }//if result_ok
        }//onactivityresult

    //TODO: Fill In Methods Etc.
    }//class
Just download the application. Run it. Enter the example. Click on the Run button to see what the rest of the code looks like.

Last edited by Phyll; 11-29-2011 at 03:36 PM..
Phyll is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 12-05-2011, 11:49 PM   #7
New Member
 
Join Date: Dec 2011
Posts: 1
Friends: 0
View monopula's Profile   View monopula's Photo Album   View monopula's Blog   View Social Groups
Maybe something from here will be useful, there are some snippets: horribile.blogspot.com
monopula is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
Old 12-19-2011, 07:53 PM   #8
New Member
 
Join Date: Dec 2011
Posts: 4
Friends: 0
View swarmconnect's Profile   View swarmconnect's Photo Album   View swarmconnect's Blog   View Social Groups
Send a message via Skype™ to swarmconnect
Stacked Overflow also tends to have a lot of excellent Android examples as does Coding Green Robots, and I've also watched the Google IO session videos that google posts after the conference each year.

Last edited by swarmconnect; 12-19-2011 at 08:48 PM..
swarmconnect is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in Technorati
 

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Android coding/development blog posts and guides Andor Site Feedback 0 04-06-2009 07:21 AM
Android Development Where to Start? Buck Android Development, Answers, Tutorials, and Code Snippets 1 03-13-2008 09:15 AM
Android Development with NetBeans Andor Android Development, Answers, Tutorials, and Code Snippets 0 03-12-2008 06:14 AM


Unlocked G1 Phones | Buy T-Mobile G1 | Google Phone

All times are GMT -6. The time now is 04:21 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.
Copyright (c) 2012 TalkAndroid.com. All rights reserved.