当我点击任何抽屉关闭时,导航抽屉中的Android

当我点击任何抽屉关闭时,导航抽屉中的Android,第1张

概述在导航抽屉中,当我按下按钮或其他任何东西时,抽屉被关闭.问题是什么?我在互联网上搜索,但我找不到任何与我的代码不同的东西.也许有一些错误,但我还没有找到它们.代码:INDEX.XML<?xmlversion="1.0"encoding="utf-8"?><android.support.v4.widget.DrawerLayoutxmlns:andr

在导航抽屉中,当我按下按钮或其他任何东西时,抽屉被关闭.问题是什么?
我在互联网上搜索,但我找不到任何与我的代码不同的东西.也许有一些错误,但我还没有找到它们.

代码:

INDEX.XML

<?xml version="1.0" enCoding="utf-8"?><androID.support.v4.Widget.DrawerLayout    xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:ID="@+ID/drawer_layout"    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"    androID:background="#bbb9b9b9">    <ListVIEw        androID:ID="@+ID/ListVIEwDrawer"        androID:layout_wIDth="240dp"        androID:layout_gravity="start"        androID:layout_height="match_parent"        androID:background="#fff"        androID:padding="3dp"        androID:choiceMode="singleChoice"        androID:divIDerHeight="1dp"        androID:divIDer="@androID:color/transparent">    </ListVIEw>    <FrameLayout        androID:ID="@+ID/content_frame"        androID:layout_wIDth="match_parent"        androID:layout_height="match_parent" />    <linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"        androID:orIEntation="vertical" androID:layout_wIDth="match_parent"        androID:layout_height="match_parent"        androID:weightSum="10">    <linearLayout        androID:orIEntation="horizontal"        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:layout_gravity="center_horizontal"        androID:weightSum="10">        <Imagebutton            androID:layout_wIDth="0dp"            androID:layout_height="fill_parent"            androID:ID="@+ID/btnMalt"            androID:layout_weight="1.5"            androID:src="@drawable/mal" />        <EditText            androID:layout_wIDth="0dp"            androID:layout_height="fill_parent"            androID:ID="@+ID/legerin_ett"            androID:layout_weight="5.5"            androID:hint="@string/legerin_text" />        <Imagebutton            androID:layout_wIDth="0dp"            androID:layout_height="fill_parent"            androID:ID="@+ID/btnLegerint"            androID:layout_weight="1.5"            androID:src="@drawable/legerin" />        <Imagebutton            androID:layout_wIDth="0dp"            androID:layout_height="fill_parent"            androID:ID="@+ID/btnDerkevet"            androID:layout_weight="1.5"            androID:src="@drawable/derkeve" />    </linearLayout>    <TextVIEw        androID:layout_wIDth="fill_parent"        androID:layout_height="wrap_content"        androID:ID="@+ID/sernavt"        androID:gravity="center"        androID:text="sepana tirşikê ji bo telefonên jîr"        androID:textStyle="bold"        androID:textcolor="#ff000000"        androID:textSize="20dp"        androID:layout_margintop="3dp"        androID:layout_marginBottom="3dp" />    <ListVIEw        androID:layout_wIDth="match_parent"        androID:layout_height="0dp"        androID:ID="@+ID/ListVIEwt"        androID:layout_gravity="center_horizontal"        androID:layout_weight="9"        androID:layout_marginBottom="5dp" />    <button        androID:layout_wIDth="fill_parent"        androID:layout_height="0dp"        androID:text="@string/peyameke_binivise"        androID:ID="@+ID/buttonPeyamBinivise"        androID:layout_gravity="center_horizontal"        androID:layout_weight="1" />    </linearLayout ></androID.support.v4.Widget.DrawerLayout>

在main.java相关代码中:

NuceMijaradapter adapter1 = new NuceMijaradapter(Index.this,R.layout.List_mijar_layout,arr);lvDrawer.setAdapter(adapter1);private class NuceMijaradapter extends ArrayAdapter<String> {    private ArrayList<String> items;    public NuceMijaradapter(Context context, int textVIEwResourceID, ArrayList<String> items) {        super(context, textVIEwResourceID, items);        this.items = items;    }    @TargetAPI(Build.VERSION_CODES.HONEYCOMB)    @OverrIDe    public VIEw getVIEw(int position, VIEw convertVIEw, VIEwGroup parent) {        VIEw v = convertVIEw;        if (v == null) {            LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);            v = vi.inflate(R.layout.List_mijar_layout, null);        }        final String o = items.get(position);        if (o != null) {            String HTMLText = o.replace("<a href=\"index.PHP?","<a href=\"http://www.tirsik.net/index.PHP?")                    .replace("padding-@R_404_6823@:8px","padding-@R_404_6823@:1px")                    .replace(" » ","");            final NuceMijarIro nuce = mijarIroAction(HTMLText);            button tvMijar = (button) v.findVIEwByID(R.ID.tvMijar);            button tvHejmar = (button) v.findVIEwByID(R.ID.tvHejmar);            tvMijar.setText(nuce.mijar);            tvHejmar.setText(nuce.hejmar);            tvMijar.setonClickListener(new VIEw.OnClickListener() {                @OverrIDe                public voID onClick(VIEw vIEw) {                    Log.d("url: ", nuce.link);                    if(nuce.link.contains("index.PHP?mijar")) {                        urlindex = nuce.link;                        if(teketin) mijarRasthatiTeketi("bnr");                        else mijarRasthati("bnr");                    }                }            });        }        return v;    }}

解决方法:

我曾经遇到过同样的问题.

我有一个RecyclerVIEw NavigationDrawer,只需将导航代码移动到xml文件的底部,我的问题就解决了.

<androID.support.v4.Widget.DrawerLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"xmlns:app="http://schemas.androID.com/apk/res-auto"androID:ID="@+ID/DrawerLayout"androID:layout_wIDth="match_parent"androID:layout_height="match_parent"androID:elevation="7dp"><relativeLayoutandroID:layout_wIDth="match_parent"androID:layout_height="match_parent">//some code here for the body of your activity</relativeLayout><androID.support.v7.Widget.RecyclerVIEw    androID:ID="@+ID/RecyclerVIEw"    androID:layout_wIDth="350dp"    androID:layout_height="match_parent"    androID:layout_gravity="right"    androID:background="#ffffff"    androID:scrollbars="vertical"></androID.support.v7.Widget.RecyclerVIEw>

希望它也适合你…

总结

以上是内存溢出为你收集整理的当我点击任何抽屉关闭时,导航抽屉中的Android全部内容,希望文章能够帮你解决当我点击任何抽屉关闭时,导航抽屉中的Android所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1101629.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存