安卓Softkeyboard输入的数值成的EditText非常缓慢 [英] Android Softkeyboard enter the numeric value into edittext very slow
问题描述
我有TableLayout,其中包含products.Each的行数包含code,说明数量,价格,折扣值,.....依赖于用户输入数量,折扣值,优惠数量和放大器;其他一些价值也会计算。
在EDITTEXT软键盘上的用户点击会这个还行,做工精细
我的问题是,当用户preSS数字键很慢,在EditText上显示。
例如我有preSS 3的键盘,经过7秒或8秒只显示它在那个特定的editText.How我可以缩短这个时间线...
这是我的产品形象:
请任何人说明为什么出现这种情况?
code是这样的:
的for(int i = initil; I<结束;我++){
.............
............
最后的EditText txtQty =新的EditText(本);
txtQty.setHeight(1);
txtQty.setLayoutParams(新的LayoutParams(LayoutParams.WRAP_CONTENT,42));
txtQty.setInputType(InputType.TYPE_CLASS_PHONE);
txtQty.setImeOptions(EditorInfo.IME_ACTION_DONE);
txtQty.setImeOptions(EditorInfo.IME_ACTION_NEXT);
txtQty.setSelectAllOnFocus(真正的);
txtQty.setTextSize(9);
txtQty.setHint(0.0);
// txtQty.setOnEditorActionListener(新DoneOnEditorActionListener());
// txtQty.setHighlightColor(R.color.green);
tr.addView(txtQty);
InputMethodManager经理=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(txtQty,InputMethodManager.SHOW_IMPLICIT);
mgr.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,InputMethodManager.HIDE_IMPLICIT_ONLY);
((InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE))hideSoftInputFromWindow(txtQty.getWindowToken(),0);
txtQty.setOnEditorActionListener(新OnEditorActionListener(){
公共布尔onEditorAction(TextView的V,INT actionId,KeyEvent的事件){
Log.i(键盘,内部编辑文本);
.............................
}});
勾选此code动态tablelayout:
main.xml中:
< XML版本=1.0编码=UTF-8&GT?;
<滚动型的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:后台=#C0C0C0>
< RelativeLayout的
机器人:layout_width =FILL_PARENT机器人:paddingBottom会=20dip
机器人:layout_height =FILL_PARENT
机器人:后台=#C0C0C0>
< TableLayout机器人:ID =@ + ID / contact_table
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / contact_info_title
机器人:layout_marginTop =10dp
机器人:背景=@可绘制/ bgwhite_selector>
< / TableLayout>
< / RelativeLayout的>
< /滚动型>
要增加TableLayout内容使用XML文件:
< XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android机器人:ID =@ + ID /勾画
机器人:layout_width =WRAP_CONTENT机器人:背景=@色/白
机器人:layout_height =WRAP_CONTENT机器人:方向=垂直>
<的TableRow机器人:背景=@色/白的android:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT>
< TextView的Android版本:文本=>中
机器人:TEXTSIZE =18dip机器人:TEXTSTYLE =黑体的Android:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT机器人:ID =@ + ID / arrowText/>
< /的TableRow>
< / LinearLayout中>
在创建了布局sepearate行添加这在Java中code:
contact_table =(TableLayout)findViewById(R.id.contact_table);
LayoutInflater充气= getLayoutInflater();
的for(int i = 0; I< CONTACT_COUNT;我++){
LinearLayout中排=(的LinearLayout)inflater.inflate(R.layout.table_row,contact_table,假);
TextView的文字=(TextView的)row.findViewById(R.id.text);
text.setText(list_data.get(我)。总结);
contact_table.addView(行);
}
的for(int i = 0; I< contact_table.getChildCount();我++){
最后查看的行= contact_table.getChildAt(我);
row.setOnClickListener(新OnClickListener(){
@覆盖
公共无效的onClick(视图v){
// TODO自动生成方法存根
ROW_ID = contact_table.indexOfChild(行);
}
});
}
二为是循环得到动态创建的表行的点击,在加入
msg_title_text.setOnEditorActionListener(新DoneOnEditorActionListener());
相应的动作监听器:
类DoneOnEditorActionListener实现OnEditorActionListener {
@覆盖
公共布尔onEditorAction(TextView的V,INT actionId,KeyEvent的事件){
如果(actionId == EditorInfo.IME_ACTION_DONE){
Log.v(****,点击);
返回true;
}
返回false;
}
}
I have TableLayout, which contain number of products.Each row contain code, description qty , price, discount value, ..... Depends on the user enter quantity , discount value, discount quantity & some other values also will calculate.
when user click on the editText soft keyboard will come this one also ok, working fine
My problem is when user press numeric keys very slow to show in the EditText.
For example I have press 3 from keyboard, after 7 or 8 seconds only it show in that particular editText.How can I reduce this time line...
This is my product image:
Please Anybody suggest why this happening?
Code like this :
for (int i = initil; i <end; i++) {
.............
............
final EditText txtQty = new EditText(this);
txtQty.setHeight(1);
txtQty.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 42));
txtQty.setInputType(InputType.TYPE_CLASS_PHONE);
txtQty.setImeOptions(EditorInfo.IME_ACTION_DONE);
txtQty.setImeOptions(EditorInfo.IME_ACTION_NEXT);
txtQty.setSelectAllOnFocus(true);
txtQty.setTextSize(9);
txtQty.setHint("0.0");
// txtQty.setOnEditorActionListener(new DoneOnEditorActionListener());
// txtQty.setHighlightColor(R.color.green);
tr.addView(txtQty);
InputMethodManager mgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
mgr.showSoftInput(txtQty, InputMethodManager.SHOW_IMPLICIT);
mgr.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,InputMethodManager.HIDE_IMPLICIT_ONLY);
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(txtQty.getWindowToken(), 0);
txtQty.setOnEditorActionListener( new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
Log.i("KeyBoard" ,"Inside the Edit Text");
.............................
} });
Check this code for Dynamic tablelayout :
main.xml :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#C0C0C0">
<RelativeLayout
android:layout_width="fill_parent" android:paddingBottom="20dip"
android:layout_height="fill_parent"
android:background="#C0C0C0">
<TableLayout android:id="@+id/contact_table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/contact_info_title"
android:layout_marginTop="10dp"
android:background="@drawable/bgwhite_selector">
</TableLayout>
</RelativeLayout>
</ScrollView>
To add Contents of TableLayout use this xml file :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/lays"
android:layout_width="wrap_content" android:background="@color/white"
android:layout_height="wrap_content" android:orientation="vertical">
<TableRow android:background="@color/white" android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:text=">"
android:textSize="18dip" android:textStyle="bold" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="@+id/arrowText"/>
</TableRow>
</LinearLayout>
After you created sepearate rows for layouts add this in Java code :
contact_table = (TableLayout)findViewById(R.id.contact_table);
LayoutInflater inflater = getLayoutInflater();
for(int i = 0; i < contact_count ; i++) {
LinearLayout row = (LinearLayout)inflater.inflate(R.layout.table_row,contact_table, false);
TextView text = (TextView)row.findViewById(R.id.text);
text.setText(list_data.get(i).summary);
contact_table.addView(row);
}
for(int i=0;i<contact_table.getChildCount();i++){
final View row=contact_table.getChildAt(i);
row.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v){
// TODO Auto-generated method stub
row_id=contact_table.indexOfChild(row);
}
});
}
Second for is the loop getting the click of Dynamically created Table row , in that add the
msg_title_text.setOnEditorActionListener(new DoneOnEditorActionListener());
Corresponding Action listener :
class DoneOnEditorActionListener implements OnEditorActionListener {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
Log.v("*****************************", "Clicked");
return true;
}
return false;
}
}
这篇关于安卓Softkeyboard输入的数值成的EditText非常缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!