出现数字软键盘并立即更改为普通键盘

时间:2011-11-25 10:01:24

标签: android input android-edittext custom-adapter numeric-keypad

我所有的一切都在寻找我的数字软键盘和EditText的帮助。我有一个基本上有2列表的活动,其中1列可通过EditText编辑。我希望在单击EditText时显示数字电话键盘。它确实这样做但它几乎立即切换到普通键盘。有时它会切换几次?? 视图位于自定义适配器内,该适配器是this blog

的修改代码

该活动有一个xml文件,但它并未真正用于以编程方式设置。 xml文件包含linearLayout,ListView和空白textview和edittext。

public class MethodEditor extends ListActivity {

private ArrayList<String[]> thismethod = new ArrayList<String[]>();


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle icicle) {
   super.onCreate(icicle);
   Bundle extras = getIntent().getExtras().getBundle("scanparam");
   ArrayList<String> param = new ArrayList<String>();//{
   param = extras.getStringArrayList("PARAM");
   ArrayList<String> value = new ArrayList<String>();
   value = extras.getStringArrayList("VALUE");
      for (int i = 0;  i < length; i++){      
       thismethod.add(new String[]{param.get(i), value.get(i)});
    }
   setContentView(R.layout.method_editor);
   MethodEditorAdapter editorAdapter = new MethodEditorAdapter(this, thismethod ); 
   setListAdapter( editorAdapter );
}

现在是自定义适配器

class MethodAdapterView extends LinearLayout {        
    public MethodAdapterView(Context context, 
            String[] strings ) {
        super( context );

       // this.setOrientation(HORIZONTAL);        
        LinearLayout.LayoutParams Params = 
            new LinearLayout.LayoutParams(100, LayoutParams.WRAP_CONTENT);
        Params.setMargins(1, 1, 1, 1);

        TextView paramname = new TextView( context );
        paramname.setInputType(InputType.TYPE_CLASS_PHONE);
        paramname.setText(strings[0]);
        paramname.setTextSize(20f);
        paramname.setTextColor(Color.WHITE);
        addView( paramname, Params);       

        LinearLayout.LayoutParams Value = 
            new LinearLayout.LayoutParams(150, LayoutParams.WRAP_CONTENT);
        Value.setMargins(1, 1, 1, 1);

        EditText paramvalue = new EditText(context);

        paramvalue.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL );
          paramvalue.setRawInputType(InputType.TYPE_CLASS_PHONE);
          paramvalue.setText(strings[1]);
        paramvalue.setTextSize(20f );
        paramvalue.setTextColor(Color.BLACK); 

        addView( paramvalue, Value); 

    }

}

public class MethodEditorAdapter extends BaseAdapter {

private Context context;
private ArrayList<String[]>  scanparam;

public MethodEditorAdapter(Context context, ArrayList<String[]> scanparam ) { 
    this.context = context;
    this.scanparam = scanparam;
}


public View getView(int position, View convertView, ViewGroup parent) { 
    return new MethodAdapterView(this.context, scanparam.get(position) );
}

}

这应该是直截了当的东西,但我认为自定义适配器出了问题。 任何人的想法?

我认为这更多地与我的手机的querty键盘的默认设置混淆了。如果我手动将手机设置更改为手机键盘,则可以正常工作。 我可以自动执行此操作吗?

0 个答案:

没有答案
相关问题