0

こんにちは私はリストをクリックするとリストビューのアクティビティがあります。ログインが成功するとログインアクティビティに移動します。ヘッダーにアイコンが表示されます(ヘッダーはすべてのアクティビティに共通です)。これまでのところ、問題が発生したのはアクティビティを変更して同じアクティビティに戻るとアイコンが表示されますアイコンが表示されませんでした。以下は私のコードです

img = (ImageView) findViewById(R.id.red);
        Intent i = getIntent();
        Bundle b = i.getExtras();
        if (b != null) {
            boolean redonly = b.getBoolean("redonly");
            if (redOnly) {
                img.setVisibility(View.VISIBLE);
                Constants.isredonly=true;
            } else {
                img.setVisibility(View.GONE);
                Constants.isredonly=false;
            }
        } else {
            img.setVisibility(View.GONE);
        }

以下は私のログインアクティビティです

public void onClick(View v) {

                String password = etPassword.getText().toString();
                 Intent myIntent = new Intent(loginActivity.this, myActivity.class);
                 myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                if (password.equals("1234")) {
                     myIntent.putExtra("redonly", true);
                } else {
                     myIntent.putExtra("redonly", false);
                }
                startActivity(myIntent);
                finish();
            }

任意の提案をいただければ幸いです。

4

0 に答える 0