Получить значение поля редактирования текста

Принятый ответ велик, но я думаю, что лучший формат в случае, если он не сразу станет очевидным для новичков:

SELECT table_name, update_time
FROM   information_schema.tables
WHERE  table_schema = 'myDBName'
order by update_time DESC

Поскольку мы не всегда знаем, какие таблицы (таблицы) были затронуты, и у этого есть бонус дать представление о том, что было за активность, показывая наиболее недавно обновленные таблицы.

415
задан jkooker 9 November 2011 в 00:23
поделиться

1 ответ

шаг 1: создайте расположение с именем activity_main.xml

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/rl"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp"
    tools:context=".MainActivity"
    android:background="#c6cabd"
    >
    <TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="17dp"
        android:textColor="#ff0e13"
        />
    <EditText
        android:id="@+id/et"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/tv"
        android:hint="Input your country"
        />
    <Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Get EditText Text"
        android:layout_below="@id/et"
        />
</RelativeLayout>

Шаг 2: Создайте класс Main.class

public class Main extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button btn = (Button) findViewById(R.id.btn);
        final TextView tv = (TextView) findViewById(R.id.tv);
        final EditText et = (EditText) findViewById(R.id.et);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String country = et.getText().toString();
                tv.setText("Your inputted country is : " + country);
            }
        });
 }
}

, который Вы видите здесь: https://code-android-example.blogspot.com/2019/10/get-text-from-edittext-in-android.html

1
ответ дан 22 November 2019 в 23:20
поделиться
Другие вопросы по тегам:

Похожие вопросы: