私の Android アプリケーションは、SherlockFragmentActivity のサブクラスである BeginActivity を起動し、次を使用して最初のビューを表示します。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getSupportFragmentManager().findFragmentById(android.R.id.content) == null) {
Fragment f = LoginFragment.newInstance();
getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content, f, "loginfragment")
.attach(f)
.commit();
}
}
LoginFragment は、次のようなビューを示します。
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.login, container, false);
// Get pointers to text views
usernameField = (EditText) v.findViewById(R.id.usernameLog);
passwordField = (EditText) v.findViewById(R.id.passwordLog);
progressBar = (ProgressBar) v.findViewById(R.id.progressBarLog);
// Set button click listeners for both buttons
Button b = (Button) v.findViewById(R.id.loginButton);
b.setOnClickListener(this);
return v;
}
ログインをクリックすると、次のようなリスト ビューが表示されます。
BeginActivity top = (BeginActivity) getActivity();
Fragment f = OfferListFragment.newInstance();
top.getSupportFragmentManager()
.beginTransaction()
.add(android.R.id.content, f, "offerList")
.addToBackStack(f.getClass().getSimpleName())
.commit();
最後に、OfferListFragment はそのビューを次のように表示します。
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.offers, container, false);
return v;
}
今私が抱えている問題は、最終的な OfferListFragment が透明に見え、その下にログイン画面が表示されることです。背景が黒い Theme.Sherlock を使用しています。ビューの背景も手動で黒に設定する必要がありますか? または、テーマの黒は、システム上のユーザーがカスタマイズできますか? (私は Android ユーザーではありません)。
ありがとう