<tfoot id='G5LvP'></tfoot>
  • <i id='G5LvP'><tr id='G5LvP'><dt id='G5LvP'><q id='G5LvP'><span id='G5LvP'><b id='G5LvP'><form id='G5LvP'><ins id='G5LvP'></ins><ul id='G5LvP'></ul><sub id='G5LvP'></sub></form><legend id='G5LvP'></legend><bdo id='G5LvP'><pre id='G5LvP'><center id='G5LvP'></center></pre></bdo></b><th id='G5LvP'></th></span></q></dt></tr></i><div id='G5LvP'><tfoot id='G5LvP'></tfoot><dl id='G5LvP'><fieldset id='G5LvP'></fieldset></dl></div>

    <small id='G5LvP'></small><noframes id='G5LvP'>

      • <bdo id='G5LvP'></bdo><ul id='G5LvP'></ul>
        <legend id='G5LvP'><style id='G5LvP'><dir id='G5LvP'><q id='G5LvP'></q></dir></style></legend>
      1. 使用屏幕键盘键入时,Android 中的 EditText 不显示文本

        EditText in Android doesn#39;t show text when typing while using the on-screen keyboard(使用屏幕键盘键入时,Android 中的 EditText 不显示文本)

      2. <small id='XACCj'></small><noframes id='XACCj'>

          • <bdo id='XACCj'></bdo><ul id='XACCj'></ul>
            <legend id='XACCj'><style id='XACCj'><dir id='XACCj'><q id='XACCj'></q></dir></style></legend>

                <tfoot id='XACCj'></tfoot>
                <i id='XACCj'><tr id='XACCj'><dt id='XACCj'><q id='XACCj'><span id='XACCj'><b id='XACCj'><form id='XACCj'><ins id='XACCj'></ins><ul id='XACCj'></ul><sub id='XACCj'></sub></form><legend id='XACCj'></legend><bdo id='XACCj'><pre id='XACCj'><center id='XACCj'></center></pre></bdo></b><th id='XACCj'></th></span></q></dt></tr></i><div id='XACCj'><tfoot id='XACCj'></tfoot><dl id='XACCj'><fieldset id='XACCj'></fieldset></dl></div>

                    <tbody id='XACCj'></tbody>

                  本文介绍了使用屏幕键盘键入时,Android 中的 EditText 不显示文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个由 3 个 EditText 字段组成的活动(其中包括 TextViews 和一些按钮).我还有一个 AutoCompleteTextView,其中包含使用 ArrayAdapter 的字符串列表.

                  I have an activity consisting of 3 EditText fields (amongst other things like TextViews and a few buttons). I also have an AutoCompleteTextView with a list of String's using an ArrayAdapter.

                  每当我在模拟器中测试应用程序时,我可以在键盘启动时键入,但它不显示文本(它仍然提供预测),并且文本仅在键盘关闭后出现在 EditText 框中.当我在手机上测试它时也会发生这种情况.但是,如果屏幕键盘没有启动并且您只是正常输入,它会在您在模拟器上输入时显示出来.

                  Whenever I test the app in an emulator, I can type when the keyboard is up but it doesn't show the text (it still gives predictions) and the text only appears in the EditText box once the keyboard is closed down. This happens when I test it on my phone, too. However, it works and shows up as you type on the emulator if the on-screen keyboard isn't up and you're just typing normally.

                  我不知道为什么!

                  这是我的活动 XML(EditText 是前 3 个块)

                  Here is my Activity XML (where the EditText's are the top 3 blocks)

                   <?xml version="1.0" encoding="utf-8"?>
                      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                      android:id="@+id/l"
                      android:layout_width="fill_parent"
                      android:layout_height="fill_parent"
                      android:layout_x="3dp"
                      android:layout_y="5dp"
                      android:background="@drawable/gymbg" >
                  
                  
                     <AutoCompleteTextView android:id="@+id/inputExercise"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:completionThreshold="1"
                          android:inputType="text"
                          android:layout_alignParentRight="true"
                          android:layout_below="@+id/timeSet"
                          android:layout_margin="10dp"
                          android:layout_marginTop="50dp"
                          android:width="200dp" />  
                  
                      <EditText
                          android:id="@+id/inputWeight"
                          android:inputType="number"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_alignParentRight="true"
                          android:layout_below="@+id/inputExercise"
                          android:layout_margin="10dp"
                          android:layout_marginTop="50dp"
                          android:width="200dp" >
                      </EditText>
                  
                      <EditText
                          android:id="@+id/inputReps"
                          android:inputType="number"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_alignParentRight="true"
                          android:layout_below="@+id/inputWeight"
                          android:layout_margin="10dp"
                          android:layout_marginTop="50dp"
                          android:width="200dp" >
                      </EditText>
                  
                      <TextView
                          android:id="@+id/timeMain"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_centerHorizontal="true"
                          android:text="@string/timeMain"
                          android:textSize="32sp" 
                          android:textColor="#0F293B"/>
                  
                      <TextView
                          android:id="@+id/timeSet"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_below="@+id/timeMain"
                          android:layout_centerHorizontal="true"
                          android:layout_marginTop="24dp"
                          android:text="@string/timeSet" 
                          android:layout_marginBottom="50dp"
                          android:textColor="#0F293B"/>
                  
                      <TextView
                          android:id="@+id/labExercise"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_alignLeft="@+id/addbutton"
                          android:layout_alignParentLeft="true"
                          android:layout_below="@+id/timeSet"
                          android:layout_centerVertical="true"
                          android:layout_margin="10dp"
                          android:layout_marginLeft="15dp"
                          android:text="@string/labExercise"   
                          android:layout_toLeftOf="@+id/inputExercise"
                          android:textColor="#ffffff"/>
                  
                      <Button
                          android:id="@+id/addbutton"
                          android:layout_width="fill_parent"
                          android:layout_height="50dp"
                          android:layout_alignParentBottom="true"
                          android:layout_alignParentLeft="true"
                          android:layout_alignParentRight="true"
                          android:layout_margin="10dp"
                          android:text="@string/add" />
                  
                  
                      <Button
                      android:id="@+id/startStop"
                      android:layout_width="fill_parent"
                      android:layout_height="wrap_content" 
                      android:layout_above="@+id/addbutton" 
                      android:layout_alignParentLeft="true"
                      android:layout_margin="10dp"
                      android:text="@string/startStop" />
                  
                      <TextView
                          android:id="@+id/labWeight"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_alignParentLeft="true"
                          android:layout_below="@+id/inputExercise"
                          android:layout_margin="10dp"
                          android:text="@string/labWeight" 
                          android:textColor="#ffffff"/>
                  
                      <TextView
                          android:id="@+id/labReps"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_alignParentLeft="true"
                          android:layout_alignTop="@+id/inputReps"
                          android:layout_margin="10dp"
                          android:text="@string/labReps" 
                          android:textColor="#ffffff"/>
                  
                      <TextView
                          android:id="@+id/seePrevious"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_above="@+id/inputExercise"
                          android:layout_centerHorizontal="true"
                          android:layout_marginBottom="22dp"
                          android:text="@string/tapToViewPrevious" 
                          android:textColor="#505050"/>
                  
                  </RelativeLayout>
                  

                  这是我在活动中使用的代码:(我已经删除了不必要的代码)

                  and here is the code I used in my activity: (I have stripped out unneccesary code)

                  public class MyWorkoutDiary1Activity extends Activity implements OnClickListener, TextWatcher 
                  {
                  
                      TextView seePrevious;
                      DatabaseHandler db;
                  
                      AutoCompleteTextView myAutoComplete;
                  
                      ArrayList<String> exerciseType = new ArrayList<String>();
                  
                  
                      @Override
                      public void onCreate(Bundle savedInstanceState) {
                          super.onCreate(savedInstanceState);
                          setContentView(R.layout.main);
                  
                  
                          exercise = new EditText(this); 
                          exercise = (EditText)findViewById(R.id.inputExercise); 
                  
                          db = new DatabaseHandler(this);
                          exerciseType = db.getUniqueExercises();
                  
                          myAutoComplete = (AutoCompleteTextView)findViewById(R.id.inputExercise);
                  
                          myAutoComplete.addTextChangedListener(this);
                          myAutoComplete.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, exerciseType));
                  
                  
                          weight = new EditText(this); 
                          weight = (EditText)findViewById(R.id.inputWeight); 
                  
                  
                          reps = new EditText(this); 
                          reps = (EditText)findViewById(R.id.inputReps); 
                  
                      }
                  
                  }
                  

                  感谢阅读

                  推荐答案

                  好的,所以我找出了问题所在!

                  Ok, so I worked out what the issue was!

                  我没有发布的代码因为我认为它无关紧要"包含一个线程

                  The code which I didn't post because I thought it was 'irrelevant' contained a thread

                  public static Runnable updateTimerMethod = new Runnable() 
                  {
                  
                      public void run() 
                      {
                          sessionTimer.setText(TimerHandler.theTime);  
                  
                          myHandler.postDelayed(this, 0);
                  
                      }
                   }; 
                  

                  通过将 postDelayed 设置为 0,我意识到线程基本上占用了所有活动(我真的不知道如何正确解释).一旦我将其更改为... 100,然后 EditText工作.

                  I realised that the thread was basically taking up all of the activity (I don't really know how to explain that properly) by having the postDelayed as 0. Once I changed this to say... 100, then the EditText worked.

                  感谢帮助我的@NKN.

                  Thank you to @NKN who helped me.

                  这可能是针对我的,但希望这对其他人有所帮助.

                  This may be specific to me, but hopefully this will help somebody else.

                  这篇关于使用屏幕键盘键入时,Android 中的 EditText 不显示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Converting a string to an integer on Android(在Android上将字符串转换为整数)
                  Is it possible to use Espresso#39;s IdlingResource to wait until a certain view appears?(是否可以使用 Espresso 的 IdlingResource 等到某个视图出现?)
                  Integrate window tester with eclipse for testing UI(将 window tester 与 eclipse 集成以测试 UI)
                  How to press a button twice using Google UiAutomator?(如何使用 Google UiAutomator 按两次按钮?)
                  Android - Checking if editText is gt;3 before and after user input(Android - 在用户输入之前和之后检查editText是否 3)
                  Android Alert Dialog unable to find view(Android 警报对话框无法找到视图)

                  <small id='n4ebi'></small><noframes id='n4ebi'>

                    <legend id='n4ebi'><style id='n4ebi'><dir id='n4ebi'><q id='n4ebi'></q></dir></style></legend>

                    <tfoot id='n4ebi'></tfoot>
                        <tbody id='n4ebi'></tbody>

                        <bdo id='n4ebi'></bdo><ul id='n4ebi'></ul>
                        <i id='n4ebi'><tr id='n4ebi'><dt id='n4ebi'><q id='n4ebi'><span id='n4ebi'><b id='n4ebi'><form id='n4ebi'><ins id='n4ebi'></ins><ul id='n4ebi'></ul><sub id='n4ebi'></sub></form><legend id='n4ebi'></legend><bdo id='n4ebi'><pre id='n4ebi'><center id='n4ebi'></center></pre></bdo></b><th id='n4ebi'></th></span></q></dt></tr></i><div id='n4ebi'><tfoot id='n4ebi'></tfoot><dl id='n4ebi'><fieldset id='n4ebi'></fieldset></dl></div>