• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Request advise in activate a button from a popup screen....

dinooz

Lurker
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>
...
 
Back
Top Bottom