Я хочу, чтобы при запуске приложения на экране отображалось всплывающее окно (выноска). Нажатие на что-либо должно вызвать исчезновение всплывающего окна.
Я делаю это, используя этот фрагмент кода в onCreate () -
findViewById(R.id.anchor_button).post(new Runnable() {
@Override
public void run() {
SecondActivity.this.showPopupToolTip(findViewById(R.id.anchor_button), "Sample Text");
}
});
и моя функция showPopupToolTip выглядит следующим образом -
protected void showPopupToolTip(View findViewById, String string) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
TextView view = (TextView) inflater.inflate(R.layout.popup_tooltip1, null);
view.setText(string);
toolTopPopup = new PopupWindow(view, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
toolTopPopup.setOutsideTouchable(true);
toolTopPopup.setTouchable(true);
toolTopPopup.setFocusable(false);
toolTopPopup.setBackgroundDrawable(new BitmapDrawable());
toolTopPopup.setAnimationStyle(0);
toolTopPopup.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss() {
Log.e("HELLO", "On Dismiss called");
}
});
toolTopPopup.setTouchInterceptor(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
SecondActivity.this.toolTopPopup.dismiss();
return true;
}
});
toolTopPopup.showAsDropDown(findViewById(R.id.anchor_button), 0, 0);
}
Появляется всплывающее окно. Но когда я нажимаю поле EditText, клавиатура вставляется, но все, что я ввожу, не появится в моем поле EditText. Что случилось?
Если это поможет, это мой макет активности -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/ll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/anchor_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="H" />
<EditText
android:id="@+id/search_field"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Search" />
</LinearLayout>
</LinearLayout>