如果单击一个按钮,我想显示三个图像按钮以显示Web视图。但是,当我通过线性布局创建三个图像按钮时,它不是好的,因为我想显示是否单击图像按钮菜单下的按钮。但是,现在,它开始新的窗口。如果点击一个按钮,创建三个图像按钮以显示Web视图
我webview.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<Button
android:id="@+id/imageButtonHomeSelector"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/icon_home_config"
android:onClick="imageButtonHomeSelector"
/>
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="96dp" />
</RelativeLayout>
我mainactivity.java
public class MainActivity extends Activity {
private Button Homebutton, LoginButton, SettingButton;
public void onCreate(Bundle savedInstanceState) {
final Context context = this;
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
Intent intent = new Intent(getApplicationContext(), WebViewActivity.class);
startActivity(intent);
addListenerHomeButton();
// addListenerLoginButton();
// addListenerSettingButton();
}
public void addListenerHomeButton() {
Homebutton = (Button) findViewById(R.id.imageButtonHomeSelector);
Homebutton.setFocusable(true);
Homebutton.setFocusableInTouchMode(true);
Homebutton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(getApplicationContext(), WebViewActivity.class);
startActivity(intent);
}
});
}
public void addListenerLoginButton() {
LoginButton = (Button) findViewById(R.id.imageButtonLoginSelector);
// LoginButton.setFocusable(true);
LoginButton.setFocusableInTouchMode(true);
LoginButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
startActivity(intent);
}
});
}
public void addListenerSettingButton() {
SettingButton = (Button) findViewById(R.id.imageButtonSettingSelector);
SettingButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(getApplicationContext(), SettingActivity.class);
startActivity(intent);
}
});
}
}
*我想显示是否点击图像按钮菜单下的按钮* - 如果我理解正确,那么您在开始新的活动后无法显示按钮。我认为你应该看看使用片段 –