gpt4 book ai didi

java - drawerLayout 内的按钮不起作用

转载 作者:行者123 更新时间:2023-11-30 01:01:50 27 4
gpt4 key购买 nike

我对 drawerLayout 有疑问。在 drawerLayout 中,我有两个 Linearlayouts。一个是直接显示的主菜单,另一个是用抽屉滑动激活的。当我滑动抽屉菜单时,我无法点击按钮。但是当我删除第二个 linearLayout 时,抽屉中的按钮工作。我该如何解决?

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=""
android:clickable="true"
android:contextClickable="true">

<LinearLayout
android:orientation="vertical"
android:layout_gravity="left|start"
android:background="@color/list_back"
android:layout_width="250dp"
android:layout_height="match_parent"
android:onClick="setContentView"
android:contextClickable="true"
android:clickable="true">

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Ana Sayfa"
android:id="@+id/buttonAnaSayfa"
android:onClick="setContentView"
android:clickable="false"
android:contextClickable="false"
android:nestedScrollingEnabled="false" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Kalori Tablosu"
android:id="@+id/buttonKalori"
android:onClick="setContentView"
android:clickable="true"
android:contextClickable="true" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Glisemik İndeks Tablosu"
android:id="@+id/buttonGITablosu"
android:onClick="setContentView"
android:clickable="true"
android:contextClickable="true" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Vücut Kütle İndeksi"
android:id="@+id/buttonVucutKutle"
android:onClick="setContentView"
android:clickable="true"
android:contextClickable="true" />

</LinearLayout>




<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foregroundGravity="center">

<ImageButton
android:layout_width="360dp"
android:layout_height="wrap_content"
android:id="@+id/imageButtonKaloriListesi"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/kalori_listesi_button"
android:background="@null"
android:layout_marginTop="10dp"
android:foregroundGravity="center"
android:gravity="center"/>

<ImageButton
android:layout_width="360dp"
android:layout_height="wrap_content"
android:id="@+id/imageButtonGITablosu"
android:src="@drawable/gi_tablosu_button"
android:layout_below="@+id/imageButtonKaloriListesi"
android:layout_alignParentStart="true"
android:background="@null"
android:layout_marginTop="10dp"
android:foregroundGravity="center"
android:gravity="center"/>

<ImageButton
android:layout_width="360dp"
android:layout_height="wrap_content"
android:id="@+id/imageButtonBugunKaloriHesabi"
android:src="@drawable/bugun_kac_kalori_aldin_button"
android:background="@null"
android:layout_above="@+id/imageButtonVucutKutleIndeks"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:foregroundGravity="center"
android:gravity="center"/>

<ImageButton
android:layout_width="360dp"
android:layout_height="wrap_content"
android:id="@+id/imageButtonVucutKutleIndeks"
android:src="@drawable/vucut_kutle_indeksi_button"
android:background="@null"
android:layout_centerVertical="true"
android:layout_alignStart="@+id/imageButtonBugunKaloriHesabi"
android:layout_marginTop="10dp"
android:foregroundGravity="center"
android:gravity="center"/>

<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="test"
android:id="@+id/buttontest1"
android:layout_gravity="center_horizontal" />

<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="230dp"
android:layout_gravity="center_horizontal"
android:id="@+id/ad"
android:layout_marginTop="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"></LinearLayout>

</LinearLayout>

这是我的.java;

package com.azelirbrevo.glisemikindeks


public class "" extends AppCompatActivity {


//DrawerLayout drawerLayout;
//ActionBarDrawerToggle toggle;

//CharSequence actionBarTitle, appTitle;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.firstaftersplash);

ImageButton ImageButtonKaloriListesi = (ImageButton) findViewById(R.id.imageButtonKaloriListesi);

ImageButton imageButtonGITablosu = (ImageButton) findViewById(R.id.imageButtonGITablosu);

ImageButton imageButtonVucutKutleIndeks = (ImageButton) findViewById(R.id.imageButtonVucutKutleIndeks);

ImageButton imageButtonBugunKaloriHesabi = (ImageButton) findViewById(R.id.imageButtonBugunKaloriHesabi);

ImageButtonKaloriListesi.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

Intent intent = new Intent(firstAfterSplash.this, KaloriListesi.class);
startActivity(intent);


}
});

imageButtonGITablosu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

Intent intent = new Intent(firstAfterSplash.this, GITablosu.class);
startActivity(intent);


}
});

imageButtonVucutKutleIndeks.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

Intent intent = new Intent(firstAfterSplash.this, VucutKutleIndexHesaplama.class);
startActivity(intent);


}
});

imageButtonBugunKaloriHesabi.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {

Intent intent = new Intent(firstAfterSplash.this, bugunKacKaloriAldim.class);
startActivity(intent);


}
});


//drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);

//actionBarTitle = appTitle = getSupportActionBar().getTitle();


Button buttonAnasayfa = (Button) findViewById(R.id.buttonAnaSayfa);
Button buttonKalori = (Button) findViewById(R.id.buttonKalori);
Button buttonGı = (Button) findViewById(R.id.buttonGITablosu);
Button buttonVucutKutle = (Button) findViewById(R.id.buttonVucutKutle);
Button test = (Button) findViewById(R.id.buttontest1);

test.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(firstAfterSplash.this, TEST.class);
startActivity(intent);
}
});

buttonAnasayfa.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "tiklandi", Toast.LENGTH_SHORT).show();

Intent intent = new Intent(firstAfterSplash.this, GITablosu.class);
startActivity(intent);
}
});

buttonKalori.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "tiklandi", Toast.LENGTH_SHORT).show();

Intent intent = new Intent(firstAfterSplash.this, GITablosu.class);
startActivity(intent);
}
});

buttonGı.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "tiklandi", Toast.LENGTH_SHORT).show();

Intent intent = new Intent(firstAfterSplash.this, GITablosu.class);
startActivity(intent);
}
});
buttonVucutKutle.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(), "tiklandi", Toast.LENGTH_SHORT).show();

Intent intent = new Intent(firstAfterSplash.this, GITablosu.class);
startActivity(intent);
}
});
}}

this is the design

最佳答案

您可以使用抽屉导航 Activity 创建一个应用程序,您可以在此处看到自定义布局内部抽屉布局和内部布局,您可以将任何类型的小部件设置为按钮、TextView 和任何您想要的类型。

关于java - drawerLayout 内的按钮不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39289694/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com