LoginSignup
2

More than 5 years have passed since last update.

Android - 入力ボックスでテキストを長押しすると落ちる件

Posted at

入力ボックスでテキストを長押しすると落ちる件

これは長らくはまりました。。。
4系では非推奨のActivityGroupを使ってるのですが、入力ボックス内のテキストを長押しすると下記のエラーが発生。

java.lang.IllegalStateException: ActionBarContextView can only be used with android:layout_width="match_parent" (or fill_parent)

結論的には下記のように対応することで解消しました。

×

    public void showIndexNewBookList() {
        container.removeAllViews();
        Intent intent = new Intent(IndexActivityGroup.this, IndexNewBookListActivity.class)
                .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        Window childActivity = getLocalActivityManager().startActivity(IndexNewBookListActivity.TAG, intent);
        container.addView(childActivity.getDecorView());
    }

    public void showIndexNewBookList() {
        container.removeAllViews();
        Intent intent = new Intent(IndexActivityGroup.this, IndexNewBookListActivity.class)
                .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        Window childActivity = getLocalActivityManager().startActivity(IndexNewBookListActivity.TAG, intent);
        container.addView(childActivity.getDecorView(), new ViewGroup.LayoutParams(FP,FP));
    }

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2