I have 3 activities. Main activity which is the home screen with two buttons, each button should show up one of the 2 last activity. I tried many methods for multiple buttons both in intent mode and switch mode; but I still can have two working button. The first button starts its linked activity without any problem, but the second button still won't show up. Here is the java code:
package com.live.app;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;
public class MainActivity extends Activity {
Button button;
Button button01;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
addListenerOnButton();
}
public void addListenerOnButton() {
final Context context = this;
button = (Button) findViewById(R.id.buttonUrl);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(context, WoneWideo.class);
startActivity(intent);
}
});
}
public void addListenerOnButton2() {
final Context context = this;
button01 = (Button) findViewById(R.id.button01);
button01.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(context, WebViewActivity.class);
startActivity(intent);
}
});
}
}
The main layout file content:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
..........................
..............................
<Button
android:id="@+id/buttonUrl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/live_button"
android:onClick="onClick"/>
<Button
android:id="@+id/button01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/vod_button"
android:onClick="onClick"/>
</LinearLayout>
Also I have all these activities/class declared in the Manifest file.