Android EditText输入的值未显示 [英] Android EditText typed value not showing

查看:74
本文介绍了Android EditText输入的值未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的android应用程序中,我使用过Search Edittext不会显示我输入的文本,

In my android application, i have used Search Edittext is not showing the text what i have typed,

我在父母的活动中使用了两个片段.

i have used Two fragments in my parent activity.

这是我的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="@color/landingbackground"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <RelativeLayout
            android:id="@+id/hearderlayout"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:background="@color/landingheader"
            android:descendantFocusability="beforeDescendants"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/navigationmenu"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:layout_marginLeft="15dp"
                android:contentDescription="@string/app_name"
                android:onClick="drawermenu"
                android:padding="15dp"
                android:src="@drawable/menu_icon" />

            <ImageView
                android:id="@+id/settingsmenu"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_centerVertical="true"
                android:layout_marginRight="15dp"
                android:contentDescription="@string/app_name"
                android:src="@drawable/settings_icon" />

            <RelativeLayout
                android:layout_width="400dp"
                android:layout_height="wrap_content"
                android:layout_marginRight="20dp"
                android:layout_toLeftOf="@+id/communicationlayout"
                android:background="@color/Orange" >

                <EditText
                    android:id="@+id/searchedittext"
                    android:layout_width="400dp"
                    android:layout_height="50dp"
                    android:layout_centerHorizontal="true"
                    android:background="#222222"
                    android:hint="Search by asset name"
                    android:inputType="textPersonName"
                    android:paddingLeft="40dp"
                    android:textColor="@color/white" />

                <ImageView
                    android:id="@+id/searchicon"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentTop="true"
                    android:contentDescription="@string/app_name"
                    android:src="@drawable/searchicon" />
            </RelativeLayout>

            <ImageView
                android:id="@+id/communicationlayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginRight="15dp"
                android:layout_toLeftOf="@+id/settingsmenu"
                android:contentDescription="@string/app_name"
                android:src="@drawable/communication_topicon" />

            <TextView
                android:id="@+id/mylocationtitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginLeft="100dp"
                android:text="@string/mylocationtitle"
                android:textColor="@color/white"
                android:textSize="22sp"
                android:textStyle="bold" />
        </RelativeLayout>

        <FrameLayout
            android:id="@+id/coverview"
            android:layout_width="match_parent"
            android:layout_height="155dp"
            android:layout_below="@+id/hearderlayout"
            android:layout_marginTop="5dp" >
        </FrameLayout>

        <FrameLayout
            android:id="@+id/detailscontainer"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@+id/coverview"
            android:layout_marginTop="5dp" />

        <RelativeLayout
            android:id="@+id/carouselandinglayout"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_below="@+id/hearderlayout"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="90dp"
            android:background="@color/white"
            android:orientation="vertical"
            android:paddingBottom="10dp"
            android:visibility="gone" >

            <TextView
                android:id="@+id/sectorband"
                android:layout_width="fill_parent"
                android:layout_height="6dp"
                android:background="#FFFF00" />

            <ImageView
                android:id="@+id/carouselimage"
                android:layout_width="100dp"
                android:layout_height="100dp"
                android:layout_below="@+id/sectorband"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="8dp"
                android:contentDescription="@string/app_name"
                android:src="@drawable/tsave" />

            <TextView
                android:id="@+id/colorrectanle"
                android:layout_width="wrap_content"
                android:layout_height="10dp"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/sectorband"
                android:layout_marginRight="10dp"
                android:layout_marginTop="3dp"
                android:background="@drawable/defaultrectangle" />

            <TextView
                android:id="@+id/defaultfirst"
                android:layout_width="wrap_content"
                android:layout_height="10dp"
                android:layout_below="@+id/sectorband"
                android:layout_marginRight="3dp"
                android:layout_marginTop="3dp"
                android:layout_toLeftOf="@+id/colorrectanle"
                android:background="@drawable/defaultrectangle" />

            <TextView
                android:id="@+id/defaultsecond"
                android:layout_width="wrap_content"
                android:layout_height="10dp"
                android:layout_below="@+id/sectorband"
                android:layout_marginRight="3dp"
                android:layout_marginTop="3dp"
                android:layout_toLeftOf="@+id/defaultfirst"
                android:background="@drawable/powerrectangle" />

            <LinearLayout
                android:id="@+id/contentlayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/defaultsecond"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="2dp"
                android:layout_toRightOf="@+id/carouselimage"
                android:orientation="vertical" >

                <TextView
                    android:id="@+id/carouselname"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:singleLine="true"
                    android:text="Power Plant 1"
                    android:textColor="@color/black"
                    android:textSize="18sp"
                    android:textStyle="bold" />

                <View
                    android:layout_width="fill_parent"
                    android:layout_height="0.5dp"
                    android:layout_marginTop="2dp"
                    android:background="@color/addbackground" />

                <LinearLayout
                    android:id="@+id/contactLayout"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="5dp"
                    android:orientation="horizontal"
                    android:visibility="visible" >

                    <ImageView
                        android:id="@+id/carouselcall"
                        android:layout_width="45dp"
                        android:layout_height="45dp"
                        android:layout_margin="5dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/call" />

                    <ImageView
                        android:id="@+id/carouselemail"
                        android:layout_width="45dp"
                        android:layout_height="45dp"
                        android:layout_margin="3dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/email" />

                    <ImageView
                        android:id="@+id/carouselmessage"
                        android:layout_width="45dp"
                        android:layout_height="45dp"
                        android:layout_marginBottom="5dp"
                        android:layout_marginLeft="10dp"
                        android:layout_marginTop="5dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/message" />

                    <ImageView
                        android:id="@+id/carouselalert"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_margin="5dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/alert"
                        android:visibility="gone" />
                </LinearLayout>

                <View
                    android:layout_width="fill_parent"
                    android:layout_height="0.5dp"
                    android:layout_marginTop="2dp"
                    android:background="@color/addbackground" />
            </LinearLayout>

            <Button
                android:id="@+id/moretext"
                android:layout_width="50dp"
                android:layout_height="25dp"
                android:layout_below="@+id/contentlayout"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="5dp"
                android:layout_toRightOf="@+id/carouselimage"
                android:background="#29abe2"
                android:text="More"
                android:textColor="@color/white"
                android:textSize="13sp" />

            <ImageView
                android:id="@+id/communicationlinkimage"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/contentlayout"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="6dp"
                android:layout_toRightOf="@+id/moretext"
                android:contentDescription="@string/app_name"
                android:src="@drawable/carouselpopup"
                android:visibility="gone" />

            <ImageView
                android:id="@+id/carouseldownarrow"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:layout_below="@+id/contentlayout"
                android:layout_marginRight="5dp"
                android:layout_marginTop="6dp"
                android:contentDescription="@string/app_name"
                android:src="@drawable/tarrow" />

            <TextView
                android:id="@+id/textposition"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/contentlayout"
                android:layout_marginRight="20dp"
                android:layout_toLeftOf="@+id/moretext"
                android:text="kdfjkdf"
                android:textColor="@color/white"
                android:textSize="13sp"
                android:visibility="gone" />
        </RelativeLayout>
    </RelativeLayout>

    <RelativeLayout
        android:id="@+id/drawer_list"
        android:layout_width="340dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:layout_marginTop="48dp"
        android:background="@color/signupbg"
        android:choiceMode="singleChoice"
        android:dividerHeight="0dp"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/fragmentlistlayout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:weightSum="1" >

            <LinearLayout
                android:id="@+id/sectorLayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight=".5"
                android:background="@color/landingbuttondefult"
                android:onClick="onclick"
                android:padding="10dp" >

                <TextView
                    android:id="@+id/sectortext"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:text="@string/sector"
                    android:textColor="@color/white"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/assetLayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_weight=".5"
                android:background="@color/landingbuttondefult"
                android:onClick="onclick"
                android:padding="10dp" >

                <TextView
                    android:id="@+id/assettext"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:gravity="center"
                    android:text="@string/facility"
                    android:textColor="@color/white"
                    android:textSize="18sp"
                    android:textStyle="bold" />
            </LinearLayout>
        </LinearLayout>

        <View
            android:layout_width="fill_parent"
            android:layout_height="1.5dp"
            android:layout_below="@+id/fragmentlistlayout"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:background="@color/dividerline" />

        <ListView
            android:id="@+id/assetsectorlist"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_above="@+id/mileselectionlayout"
            android:layout_below="@+id/fragmentlistlayout" >
        </ListView>

        <RelativeLayout
            android:id="@+id/mileselectionlayout"
            android:layout_width="340dp"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_gravity="bottom"
            android:layout_marginBottom="20dp"
            android:background="@color/black"
            android:gravity="bottom"
            android:orientation="vertical"
            android:paddingBottom="20dp"
            android:paddingTop="20dp" >

            <TextView
                android:id="@+id/milestext"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="3dp"
                android:layout_marginTop="2dp"
                android:textColor="@color/white"
                android:textSize="16sp" />

            <LinearLayout
                android:id="@+id/linearLayout1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@+id/milestext"
                android:layout_centerVertical="true"
                android:layout_marginTop="5dp"
                android:orientation="horizontal" >

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <ImageView
                        android:id="@+id/onelevel"
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/normalgrey" />

                    <TextView
                        android:id="@+id/oneleveltext"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="3dp"
                        android:textColor="@color/white"
                        android:textSize="14sp" />
                </LinearLayout>

                <View
                    android:layout_width="28dp"
                    android:layout_height="1dp"
                    android:layout_marginTop="9dp"
                    android:background="@color/landingbuttonselected" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <ImageView
                        android:id="@+id/twolevel"
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/normalgrey" />

                    <TextView
                        android:id="@+id/twoleveltext"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/white"
                        android:textSize="14sp" />
                </LinearLayout>

                <View
                    android:layout_width="28dp"
                    android:layout_height="1dp"
                    android:layout_marginTop="9dp"
                    android:background="@color/landingbuttonselected" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <ImageView
                        android:id="@+id/thirdlevel"
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/normalgrey" />

                    <TextView
                        android:id="@+id/threeleveltext"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/white"
                        android:textSize="14sp" />
                </LinearLayout>

                <View
                    android:layout_width="28dp"
                    android:layout_height="1dp"
                    android:layout_marginTop="9dp"
                    android:background="@color/landingbuttonselected" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <ImageView
                        android:id="@+id/fourthlevel"
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/normalgrey" />

                    <TextView
                        android:id="@+id/fourleveltext"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/white"
                        android:textSize="14sp" />
                </LinearLayout>

                <View
                    android:layout_width="28dp"
                    android:layout_height="1dp"
                    android:layout_marginTop="9dp"
                    android:background="@color/landingbuttonselected" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <ImageView
                        android:id="@+id/fifthelevel"
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/normalgrey" />

                    <TextView
                        android:id="@+id/fiveleveltext"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/white"
                        android:textSize="14sp" />
                </LinearLayout>

                <View
                    android:layout_width="28dp"
                    android:layout_height="1dp"
                    android:layout_marginTop="9dp"
                    android:background="@color/landingbuttonselected" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:orientation="vertical" >

                    <ImageView
                        android:id="@+id/sixthlevel"
                        android:layout_width="30dp"
                        android:layout_height="30dp"
                        android:contentDescription="@string/app_name"
                        android:src="@drawable/normalgrey" />

                    <TextView
                        android:id="@+id/sixleveltext"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/white"
                        android:textSize="14sp" />
                </LinearLayout>
            </LinearLayout>
        </RelativeLayout>
    </RelativeLayout>

</android.support.v4.widget.DrawerLayout>

在我的活动中:

mSearchText = (EditText) findViewById(R.id.searchedittext);

        mSearchText.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before,
                    int count) {

//code
                }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count,
                    int after) {

            }

            @Override
            public void afterTextChanged(Editable s) {

            }
        });

我的清单:

 <activity
            android:name=".....LandingActivity"
            android:label="@string/app_name"
            android:screenOrientation="sensorLandscape"
            android:windowSoftInputMode="adjustPan" >
        </activity>

任何人都可以帮助我获得解决方案吗?我已经全神贯注地尝试了

Can anyone help me to get solution?? i have tried with focus and all

感谢Adapance

Thanks in Adavance

推荐答案

android:hardwareAccelerated="true"

这篇关于Android EditText输入的值未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆