0

電話用の通常の全画面アクティビティと、バックアクティビティの上にあるタブレット用のカスタム計算サイズが必要なアプリのカスタム設定アクティビティを作成しようとしています。しかし、私はこれにいくつかの問題を抱えています。

public class ActivityAppSettings extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        if (getApplication() != null && ((ApplicationBase) getApplication()).mTheme > 0) {
            setTheme( ((ApplicationBase) getApplication()).mTheme );
        }

        super.onCreate(savedInstanceState);

        getWindow().setBackgroundDrawable(new ColorDrawable(0));
        getWindow().setLayout(800, 600);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        setContentView(R.layout.activity_app_settings);
    }
}

これは私のアクティビティです (これはテスト用に設定されているだけなので、タブレットのチェックなどはまだありません)。こちらも何とか動いています。タイトルがありません。コンテンツのサイズは、設定した幅と高さだけを埋め、画面の中央に配置されます。ただし、コンテンツの周囲の背景は透明ではありません。

私はいくつかのグローバル カスタム テーマを持っているので、それらを Dialog に変更すると、ウィンドウ内のコンテンツのテーマが上書きされてしまうため、役に立ちません。ただし、問題を特定するために、ダイアログ テーマを Android のダイアログ テーマに変更しようとしました。これもうまくいきませんでした。コンテンツの周りのまだ黒い背景。

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.menu_controller_app_settings:
            Intent intent = new Intent(this, ActivityAppSettings.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

            startActivity(intent);

            return true;

        default:
        return super.onOptionsItemSelected(item);
    }
}

これは、アクティビティがメイン アクティビティ内から開始される場所です。多分これは私が何かが欠けているところですか?

4

1 に答える 1

1

以下のコードを試してください。

 public class AlertDialogActivity extends Activity {
 private Context mContext;
 private String message;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
    mContext = this;
    super.onCreate(savedInstanceState);

        final Dialog myDialog = new Dialog(mContext);
        myDialog.setContentView(R.layout.dialog_layout);
        myDialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
        TextView titleTextView = (TextView) myDialog
                .findViewById(R.id.DialogTitleTextView);
        TextView messageTextView = (TextView) myDialog
                .findViewById(R.id.DialogMessageTextView);
        Button okButton = (Button) myDialog
                .findViewById(R.id.DialogOkButton);
        Button cancelButton = (Button) myDialog
                .findViewById(R.id.DialogCancelButton);
        titleTextView.setText(mContext.getString(R.string.app_name));
        titleTextView.setTypeface(Calculations
                .getBoldTypeFaceInstance(mContext));
        messageTextView.setText(message);
        messageTextView.setTypeface(Calculations
                .getRegularTypeFaceInstance(mContext));
        okButton.setTypeface(Calculations.getBoldTypeFaceInstance(mContext));


        myDialog.show();

  } 
}
于 2013-07-01T06:28:01.203 に答える