代码之家  ›  专栏  ›  技术社区  ›  irobotxx

从EditableText android动态获取文本

  •  0
  • irobotxx  · 技术社区  · 15 年前

    我正在尝试从EditText小部件中获取文本输入/值作为其输入。请大家知道我该怎么用或用什么方法?似乎找不到一个有用的。谢谢你的考虑。

    我试过但没成功:

      Entry = (EditText)findViewById(R.id.typeEntryId);
              viewEntry = (TextView)findViewById(R.id.viewEntryId);
    
           if(Entry != null){
                //viewEntry.setText(Entry.getEditableText().toString());
                      viewEntry.setText(Entry.getText().toString());
            }
    
    2 回复  |  直到 15 年前
        1
  •  2
  •   Cheryl Simon    15 年前
        2
  •  0
  •   Ryan Conrad    15 年前
    EditText field = (EditText) findViewById(R.id.myField);
    if ( field != null ) {
      Log.d ("myField",field.getText().toString());
    }
    

    你应该能做到。这个 getText() 方法返回 Editable CharSequence