久久久久久久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問題)
主站蜘蛛池模板: 日韩免费视频一区二区 | 欧美成人精品在线观看 | 亚洲精品一区二区三区在线 | 99re6在线视频 | 精品亚洲一区二区 | 999久久久久久久久 国产欧美在线观看 | av影音资源 | 国产真实乱对白精彩久久小说 | 欧美日韩成人在线观看 | 三级视频在线观看电影 | 国产有码| 日本高清aⅴ毛片免费 | 国产第一页在线观看 | 操操操日日日 | 国产成人自拍av | 国产欧美日韩在线 | 国产成人免费视频网站视频社区 | a爱视频 | 日韩免费一区二区 | 日韩aⅴ视频 | 久久人爽爽人爽爽 | 国产亚洲区 | 天堂成人av | 久久久久久国产精品免费 | 免费黄色在线观看 | 日本精品久久久久久久 | 国产精品揄拍一区二区 | 国产精品久久亚洲 | 国产成人精品999在线观看 | 色婷婷av99xx| 亚洲精品国产成人 | 亚洲 欧美 日韩 在线 | 成人av一区二区三区 | 国产一区中文 | 精品久久一区 | 91免费视频观看 | 精品一区在线 | 亚洲精品自拍视频 | 国产女人叫床高潮大片免费 | 国产精品久久久久久久久久久久 | 成人免费一级视频 |