久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Listview android中的Edittext

Edittext in Listview android(Listview android中的Edittext)
本文介紹了Listview android中的Edittext的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我有帶有 editext 和 textview 的 Listview.

I have Listview with editext and textview.

當我觸摸 edittext 時,edittext 失去焦點!

When i touch on edittext then edittext lost focus!

我通過設置 android:windowSoftInputMode="adjustPan"(AndroidManifest.xml) 解決了這個問題.現在我觸摸edittext而不是editext獲得焦點,但應用程序標簽和一些原始列表視圖消失(頂部).

I resolved this problem by setting android:windowSoftInputMode="adjustPan"(AndroidManifest.xml). Now i touch on edittext than editext get focus but application label and some raw of listview disappear(top part).

我想在用戶觸摸 edittext 時獲得焦點,而不會丟失應用程序標簽和一些原始列表視圖.

I want to get focus when user touch on edittext without loss application label and some raw of listview.

我已經實現的代碼:

當用戶觸摸edittext但應用程序標簽和一些原始列表視圖在軟鍵盤彈出時消失時,下面的代碼獲得焦點.我想在用戶觸摸edittext時獲得焦點而不丟失應用程序標簽和一些原始列表視圖.

Below coding get focus when user touch on edittext but application label and some raw of listview disappear when soft keypad pop up.I want to get focus when user touch on edittext without loss application label and some raw of listview.

1)AndroidManifest.xml

1)AndroidManifest.xml

<application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".MyListViewDemoActivity"
                  android:label="@string/app_name"
                  android:windowSoftInputMode="adjustPan"
                  >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

</application>

2) raw_layout.xml

2) raw_layout.xml

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <EditText android:id="@+id/mEditText"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  />  
</LinearLayout>

3) main.xml

3) main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<ListView android:id="@+id/mListView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>

4) MyListViewDemoActivity

4) MyListViewDemoActivity

public class MyListViewDemoActivity extends Activity {
    private ListView mListView;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mListView=(ListView)findViewById(R.id.mListView);
        mListView.setAdapter(new MyAdapter(this));
    }
}

class MyAdapter extends BaseAdapter {

    private Activity mContext;
    private String character[]={"a","b","c","d","e","f","g","h","i","j"};
    public MyAdapter(Activity context)
    {
        mContext=context;
    }

    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return character.length;
    }

    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }
private class Holder
{
    EditText mEditText;
}
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        final Holder holder;
        if (convertView == null) {
            holder = new Holder();
            LayoutInflater inflater =mContext.getLayoutInflater();
            convertView = inflater.inflate(R.layout.raw_layout, null);
            holder.mEditText = (EditText) convertView
                    .findViewById(R.id.mEditText);
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
        holder.mEditText.setText(character[position]);
        holder.mEditText.setOnFocusChangeListener(new OnFocusChangeListener() {

            @Override
            public void onFocusChange(View v, boolean hasFocus) {
                // TODO Auto-generated method stub
                if (!hasFocus){
                    final EditText etxt = (EditText) v;
                    holder.mEditText.setText(etxt.getText().toString());
                }

            }
        });
        return convertView;
    }

}

推薦答案

我也遇到了同樣的問題.我的數字鍵盤會在被 qwerty 鍵盤替換之前暫時出現,并且 EditText 失去焦點.

I was having the same problem. My numberic keyboard would momentarily appear before being replaced by the qwerty keyboard and the EditText losing focus.

問題是出現的鍵盤使您的 EditText 失去焦點.為防止這種情況發生,請在您的 AndroidManifest.xml 中為適當的活動(或活動)添加以下內容:

The problem is that the keyboard appearing makes your EditText lose focus. To prevent this put the following in your AndroidManifest.xml for the appropriate Activity (or Activities):

android:windowSoftInputMode="adjustPan"

請參閱 Android 文檔:

See Android documentation:

當輸入法出現在屏幕上時,它會減少可用于應用 UI 的空間量.系統會決定如何調整 UI 的可見部分,但它可能無法正確處理.為確保您的應用獲得最佳行為,您應該指定您希望系統如何在剩余空間中顯示您的 UI.

When the input method appears on the screen, it reduces the amount of space available for your app's UI. The system makes a decision as to how it should adjust the visible portion of your UI, but it might not get it right. To ensure the best behavior for your app, you should specify how you'd like the system to display your UI in the remaining space.

要在活動中聲明您的首選處理方式,請在清單的 <activity> 元素中使用 android:windowSoftInputMode 屬性和adjust"之一.價值觀.

To declare your preferred treatment in an activity, use the android:windowSoftInputMode attribute in your manifest's <activity> element with one of the "adjust" values.

例如,為了確保系統將您的布局調整到可用空間——這確保所有布局內容都可以訪問(即使它可能需要滾動)——使用 adjustResize"

For example, to ensure that the system resizes your layout to the available space—which ensures that all of your layout content is accessible (even though it probably requires scrolling)—use "adjustResize"

這篇關于Listview android中的Edittext的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Cut, copy, paste in android(在android中剪切、復制、粘貼)
android EditText blends into background(android EditText 融入背景)
Change Line Color of EditText - Android(更改 EditText 的線條顏色 - Android)
EditText showing numbers with 2 decimals at all times(EditText 始終顯示帶 2 位小數的數字)
Changing where cursor starts in an expanded EditText(更改光標在展開的 EditText 中的開始位置)
EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView問題)
主站蜘蛛池模板: 亚洲性网 | 成人免费视频 | 日韩字幕 | 亚洲成人福利视频 | 狠狠操在线| 97色在线观看免费视频 | 一区精品视频 | 久久久久国产精品 | 中文字幕一区二区三区精彩视频 | 国产精品成人一区二区 | 国产欧美性成人精品午夜 | 中文字幕亚洲在线 | 婷婷久久网 | 成人精品网 | 黑人巨大精品欧美一区二区免费 | 一级片成人 | 国产色网站| 亚洲精品一区二区网址 | av资源中文在线 | 黄色欧美| 国产美女h视频 | 天天看夜夜 | 一区二区三区免费网站 | av在线视| 国产 日韩 欧美 中文 在线播放 | 久久久青草婷婷精品综合日韩 | 91精品国产777在线观看 | 午夜在线视频 | 日日日干干干 | 免费爱爱视频 | 久久骚 | 成人精品一区二区 | 欧美日韩91| 福利片在线观看 | 毛片网站在线观看 | 中文字幕精品一区 | 在线免费中文字幕 | 亚洲一区亚洲二区 | 红桃视频一区二区三区免费 | 精品一二区 | 成人免费视频 |