noob Question button functions

by MarQuel Middleton » Sun, 13 Sep 2009 04:59:50 GMT


Sponsored Links
 Hey im a new developer ans im having trouble with button functions i
have a menu created but how do i give them functions so when there
pressed they can actually do something?

--~--~---------~--~----~------------~-------~--~----~



noob Question button functions

by Mark Murphy » Sun, 13 Sep 2009 05:02:37 GMT


 


If you implemented an options menu, override onOptionItemSelected() in
your activity.

If you implemented a context menu, override onContextItemSelected() in
your activity.

If you implemented one or more Button widgets, not a menu, call
setOnClickListener() on the widget and supply a listener object to be
notified when the button is clicked.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android Training in Germany, 18-22 January 2010:  http://bignerdranch.com 

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


noob Question button functions

by MarQuel Middleton » Sun, 13 Sep 2009 06:09:39 GMT


 Thank You!!





--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Application did not load to market place now the app is gone, please help

I tried to upload an update to my app but I got the following now my
app has disappeared from my interface and i cannot load an app with
the same name,

You have another published application on Market with the same package
name (com.x.x). Go to that other application, and click upgrade.

I cannot update or re-publish my app, please help

does anybody know how to fix this?



--~--~---------~--~----~------------~-------~--~----~

2. Is it possible to have 2 launcher Activity in a single apk?



I tried that but it seems I'm still doing something wrong (see code at
the end of the message). The results I get are:
* Two launcher entries (Ativity A and Activity B) are placed in the
activity list in Home
* Clicking first on Activity A will start Activity A.
* Going back and clicking on Activity B will start Activity A again.
* If I click on Activity B the first time after install, B is started
and going back -> clicking on A, starts B again

Any hints on what I'm doing wrong?


LogCat:
INFO/ActivityManager(55): Starting activity: Intent {
action=android.intent.action.MAIN
categories={android.intent.category.LAUNCHER} flags=0x10200000
comp={test.activity/test.activity.ActivityA} }
INFO/ActivityManager(55): Start proc test.activity for activity
test.activity/.ActivityA: pid=13716 uid=10036 gids={}
INFO/jdwp(13716): received file descriptor 10 from ADB
INFO/ActivityManager(55): Displayed activity test.activity/.ActivityA: 872 ms
INFO/ActivityManager(55): Starting activity: Intent {
action=android.intent.action.MAIN
categories={android.intent.category.HOME} flags=0x10200000
comp={com.android.launcher/com.android.launcher.Launcher} }
INFO/ActivityManager(55): Starting activity: Intent {
action=android.intent.action.MAIN
categories={android.intent.category.LAUNCHER} flags=0x10200000
comp={test.activity/test.activity.ActivityB} }

Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="test.activity"
      android:versionCode="1"
      android:versionName="1.0.0">
    <application>

        <activity android:name=".ActivityA" android:label="Activity A">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".ActivityB" android:label="Activity B">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
                
    </application>
</manifest>


public class ActivityA extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        tv.setText("ActivityA");
        setContentView(tv);
    }

}


public class ActivityB extends Activity {
        
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        tv.setText("ActivityB");
        setContentView(tv);
    }
}

--~--~---------~--~----~------------~-------~--~----~

3. 2 questions about Browser

4. is Android Market removing useless comments now?

5. Camera Preview Sizing

6. The Widget used for the Main Menu in android Home Screen

7. ImageButton resizes within TableLayout -- How do i fix?