Я бы хотел, чтобы клавиатура открывалась при запуске моей активности.Я попробовал все методы / ответы с вопросами ниже, но не повезло.
Я считаю, что проблема в том, что когда аппаратная клавиатура доступна, поведение по умолчанию для программной клавиатуры не отображается.Может ли это быть отменено?Что произойдет, если аппаратная клавиатура будет скрыта?
Я безуспешно прочитал следующие вопросы.Ближайшая проблема, с которой я столкнулся, находится здесь: Вопрос 2712822
Другие вопросы:
Вопрос 3379403
Вопрос 2479504
Main.xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:id="@+id/scrollView1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:layout_width="match_parent" android:id="@+id/linearLayout1" android:layout_height="match_parent" android:orientation="vertical">
<LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout2" android:layout_gravity="center" android:layout_width="match_parent">
<TextView android:layout_height="wrap_content" android:text="TextView" android:layout_width="wrap_content" android:id="@+id/textView1"></TextView>
<EditText android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/testText" android:focusable="true" android:focusableInTouchMode="true" android:hint="Input here"></EditText>
</LinearLayout>
<LinearLayout android:layout_height="match_parent" android:id="@+id/linearLayout2" android:layout_gravity="center" android:layout_width="match_parent">
<TextView android:layout_height="wrap_content" android:text="TextView" android:layout_width="wrap_content" android:id="@+id/textView1"></TextView>
<EditText android:id="@+id/editText1" android:layout_height="wrap_content" android:layout_width="fill_parent" android:hint="and here"></EditText>
</LinearLayout>
</LinearLayout>
</ScrollView>
Мой основной код активности выглядит следующим образом:
package com.example.example3;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
public class example3 extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
EditText edit = (EditText)this.findViewById(R.id.testText);
edit.requestFocus();
/* // Below Doesn't work
InputMethodManager imm = (InputMethodManager)
example3.this.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null){/ imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
}
//Below Doesn't work
// getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
*/
}
}
Это безнадежная причина?Может кто-нибудь проверить это на телефоне с закрытой аппаратной клавиатурой и сказать, что происходит?