简体   繁体   中英

Android softkeyboard show/hide control problem

Here I wrote simple layout xml. (with one listview and edittext)

When I activate this xml using common setContentView(R.layout.main); soft keyboard is always appears from the bottom side. BUT, when I remove listview entry from xml, softkeyboard is not shown.

I have no idea what's the relation between listview and softkeyboard.

I searched similar questions from this site, and some articles mentioned solution using focus control. But I want my xml have default focus at edittext without soft keyboard.

Can someone give me an advise to how to solve this problem?

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="480px"
    android:layout_height="762px"
    android:layout_gravity="center"
    android:background="@drawable/bg_blank"
    >

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >

        <ListView
            android:id="@+id/mylist"
            android:layout_width="100px"
            android:layout_height="200px"
            android:layout_marginLeft="0px"
            android:layout_marginTop="70px"
            />

        <EditText 
            android:id="@+id/input1"
            android:layout_width="200px"
            android:layout_height="50px"
            android:layout_marginLeft="64px"
            android:layout_marginTop="400px"        
            />
    </RelativeLayout>

</FrameLayout>

尝试将此属性添加到清单文件中的活动中

<activity android:windowSoftInputMode="stateAlwaysHidden" android:name=".Demo"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM