Я разрабатываю приложение для Android. Активность имеет tabhost с 5 вкладками. На второй вкладке есть виджет edittext. Когда я нажимаю, я хочу, чтобы клавиатура отображалась. Как получить фокус на виджете edittext из tabhost? Как открыть клавиатуру Android в табусте на клике edititext?
Вот мой Java-код:
public class activities extends AppCompatActivity {
public static final int CAPTURE_IMAGE = 2;
ImageView imageView;
Button btnCapturePicture;
File file;
static int count=0;
String imgPath,selectedImagePath;
EditText editText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activities);
editText=(EditText)findViewById(R.id.editText8);
TabHost th=(TabHost)findViewById(R.id.tabHost);
th.setup();
TabHost.TabSpec specs=th.newTabSpec("Tag1");
specs.setContent(R.id.camera);
specs.setIndicator("",getResources().getDrawable(R.drawable.camera));
th.addTab(specs);
specs=th.newTabSpec("Tag2");
specs.setContent(R.id.chat);
specs.setIndicator("",getResources().getDrawable(R.drawable.chat15));
th.addTab(specs);
specs=th.newTabSpec("Tag3");
specs.setContent(R.id.profile);
specs.setIndicator("",getResources().getDrawable(R.drawable.user_blue));
th.addTab(specs);
specs=th.newTabSpec("Tag4");
specs.setContent(R.id.history);
specs.setIndicator("",getResources().getDrawable(R.drawable.history2));
th.addTab(specs);
specs=th.newTabSpec("Tag5");
specs.setContent(R.id.settings);
specs.setIndicator("",getResources().getDrawable(R.drawable.settings5));
th.addTab(specs);
imageView = (ImageView)findViewById(R.id.imageview6);
btnCapturePicture=(Button)findViewById(R.id.btnCapturePicture);
btnCapturePicture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, setImageUri());
startActivityForResult(intent, CAPTURE_IMAGE);
}
});
}
Я получаю сообщение об ошибке. не может разрешить метод gettabhost(), если класс действия расширяет appcompatactivity. но если tabactivity расширен, gettabhost() не показывает ошибки. но R.id.tabhost показывает сообщение об ошибке. –