Go Back   Android Forums > Android Discussion > Android Lounge
Android Lounge A place for general Android discussion and questions.

Get excited for the Samsung Galaxy S5! Find everything you need and discuss it in our Galaxy S5 Forum!

test: Reply
 
LinkBack Thread Tools
Old August 17th, 2010, 08:28 AM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Jul 2010
Posts: 3
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default Request advise in activate a button from a popup screen....

Hey Guys, I like to activate a popup navigation window, which redirect me to a particular activity... got this working from the regular button, but when I like to run it from a popup the buttons quit working. please advise on how to activate a button from a popup screen.


Here is what I got working ... the manifest...
.....
<activity android:name=".Welcome"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Welcome2"></activity>
<activity android:name=".Welcome3"></activity>
<activity android:name=".Welcome4"></activity>
....

As a buton in the main.xml:
....
<Button android:text="Next"
android:id="@+id/Button01"
android:layout_width="50px"
android:textSize="18px"
android:layout_height="55px">
</Button>

<Button android:text="2"
android:id="@+id/Button02"
android:layout_width="50px"
android:textSize="18px"
android:layout_height="55px">
</Button>

<Button android:text="3"
android:id="@+id/Button03"
android:layout_width="50px"
android:textSize="18px"
android:layout_height="55px">
</Button>
.....

The Java code is:
....
Button next = (Button) findViewById(R.id.Button01);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), Welcome2.class);
startActivityForResult(myIntent, 0);
}
});

Button next2 = (Button) findViewById(R.id.Button02);
next2.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), Welcome3.class);
startActivityForResult(myIntent, 0);
}
});

Button next3 = (Button) findViewById(R.id.Button03);
next3.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), Welcome4.class);
startActivityForResult(myIntent, 0);
}
});

Example Welcome2.class......

....
public class Welcome2 extends Activity {

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);

Button next = (Button) findViewById(R.id.Button02);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent();
setResult(RESULT_OK, intent);
finish();
}

});
}
}
....

When click each of the buttons switch to the appropiate main2.xml or main3.xml or main4.xml.... as expected...

Now I want this buttons in a popup.....

For the main.xml one button to call the popup...

<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/Button01main"
android:text="Hey! There is more...">
</Button>

The java code:

Button mypopup = (Button) findViewById(R.id.Button01main);
mypopup.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Dialog dialog = new Dialog(Welcome.this);
dialog.setTitle("This is PopUp Window");
dialog.setContentView(R.layout.custom_dialog);


Button next = (Button) findViewById(R.id.Button01);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), Welcome2.class);
startActivityForResult(myIntent, 0);
}
});

dialog.show();
}
});

Now the custom_dialog.xml is:

...
<Button android:text="Section 1"
android:id="@+id/Button01"
android:textSize="18px"
android:layout_width="fill_parent"
android:layout_height="60px">
</Button>

<Button android:text="Section 2"
android:id="@+id/Button02"
android:layout_width="fill_parent"
android:textSize="18px"
android:layout_height="60px">
</Button>

<Button android:text="Section 3"
android:id="@+id/Button03"
android:layout_width="fill_parent"
android:textSize="18px"
android:layout_height="60px">
</Button>
...

dinooz is offline  
Reply With Quote
sponsored links
Reply
Tags
activity, button, navigations, popup


Go Back   Android Forums > Android Discussion > Android Lounge
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 03:36 PM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.