pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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 失去焦點.為防止這種情況發(fā)生,請在您的 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 的空間量.系統(tǒng)會決定如何調整 UI 的可見部分,但它可能無法正確處理.為確保您的應用獲得最佳行為,您應該指定您希望系統(tǒng)如何在剩余空間中顯示您的 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.

例如,為了確保系統(tǒng)將您的布局調整到可用空間——這確保所有布局內容都可以訪問(即使它可能需要滾動)——使用 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模板網!

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

相關文檔推薦

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問題)
主站蜘蛛池模板: 刘秘书_你身边专业的工作范文写作小秘书 | 谷歌关键词优化-外贸网站优化-Google SEO小语种推广-思亿欧外贸快车 | 亮化工程,亮化设计,城市亮化工程,亮化资质合作,长沙亮化照明,杰奥思【官网】 | 众能联合-提供高空车_升降机_吊车_挖机等一站工程设备租赁 | 钢格板_钢格栅_格栅板_钢格栅板 - 安平县鑫拓钢格栅板厂家 | 大倾角皮带机-皮带输送机-螺旋输送机-矿用皮带输送机价格厂家-河南坤威机械 | 一体式钢筋扫描仪-楼板测厚仪-裂缝检测仪-泰仕特(北京) | 河南膏药贴牌-膏药代加工-膏药oem厂家-洛阳今世康医药科技有限公司 | Trimos测长机_测高仪_TESA_mahr,WYLER水平仪,PWB对刀仪-德瑞华测量技术(苏州)有限公司 | 根系分析仪,大米外观品质检测仪,考种仪,藻类鉴定计数仪,叶面积仪,菌落计数仪,抑菌圈测量仪,抗生素效价测定仪,植物表型仪,冠层分析仪-杭州万深检测仪器网 | 萃取箱-萃取槽-PVC萃取箱厂家-混合澄清槽- 杭州南方化工设备 | 志高装潢官网-苏州老房旧房装修改造-二手房装修翻新 | 多米诺-多米诺世界纪录团队-多米诺世界-多米诺团队培训-多米诺公关活动-多米诺创意广告-多米诺大型表演-多米诺专业赛事 | 山东锐智科电检测仪器有限公司_超声波测厚仪,涂层测厚仪,里氏硬度计,电火花检漏仪,地下管线探测仪 | 济南玻璃安装_济南玻璃门_济南感应门_济南玻璃隔断_济南玻璃门维修_济南镜片安装_济南肯德基门_济南高隔间-济南凯轩鹏宇玻璃有限公司 | 艺术涂料_进口艺术涂料_艺术涂料加盟_艺术涂料十大品牌 -英国蒙太奇艺术涂料 | 二维运动混料机,加热型混料机,干粉混料机-南京腾阳干燥设备厂 | 澳门精准正版免费大全,2025新澳门全年免费,新澳天天开奖免费资料大全最新,新澳2025今晚开奖资料,新澳马今天最快最新图库 | 网站建设,北京网站建设,北京网站建设公司,网站系统开发,北京网站制作公司,响应式网站,做网站公司,海淀做网站,朝阳做网站,昌平做网站,建站公司 | 电液推杆生产厂家|电动推杆|液压推杆-扬州唯升机械有限公司 | 立式_复合式_壁挂式智能化电伴热洗眼器-上海达傲洗眼器生产厂家 理化生实验室设备,吊装实验室设备,顶装实验室设备,实验室成套设备厂家,校园功能室设备,智慧书法教室方案 - 东莞市惠森教学设备有限公司 | 炭黑吸油计_测试仪,单颗粒子硬度仪_ASTM标准炭黑自销-上海贺纳斯仪器仪表有限公司(HITEC中国办事处) | ERP企业管理系统永久免费版_在线ERP系统_OA办公_云版软件官网 | 螺杆式冷水机-低温冷水机厂家-冷冻机-风冷式-水冷式冷水机-上海祝松机械有限公司 | 煤矿人员精确定位系统_矿用无线通信系统_煤矿广播系统 | 济南货架定做_仓储货架生产厂_重型货架厂_仓库货架批发_济南启力仓储设备有限公司 | 青海电动密集架_智能密集架_密集架价格-盛隆柜业青海档案密集架厂家 | 冷却塔厂家_冷却塔维修_冷却塔改造_凉水塔配件填料公司- 广东康明节能空调有限公司 | 新能源汽车电机定转子合装机 - 电机维修设备 - 睿望达 | 海南在线 海南一家| 合肥地磅_合肥数控切割机_安徽地磅厂家_合肥世佳电工设备有限公司 | 济南品牌设计-济南品牌策划-即合品牌策划设计-山东即合官网 | 环保袋,无纺布袋,无纺布打孔袋,保温袋,环保袋定制,环保袋厂家,环雅包装-十七年环保袋定制厂家 | 自动售货机_无人售货机_专业的自动售货机运营商_免费投放售货机-广州富宏主官网 | 老房子翻新装修,旧房墙面翻新,房屋防水补漏,厨房卫生间改造,室内装潢装修公司 - 一修房屋快修官网 | 底部填充胶_电子封装胶_芯片封装胶_芯片底部填充胶厂家-东莞汉思新材料 | 游泳池设计|设备|配件|药品|吸污机-东莞市太平洋康体设施有限公司 | 洁净化验室净化工程_成都实验室装修设计施工_四川华锐净化公司 | 电缆桥架生产厂家_槽式/梯式_热镀锌线槽_广东东莞雷正电气 | 2025世界机器人大会_IC China_半导体展_集成电路博览会_智能制造展览网 | 郑州水质检测中心_井水检测_河南废气检测_河南中环嘉创检测 |