0

I have an activity with a list view and a common header with hidden icon.. when I click the listview a loginscreen will be triggered and when the login is successfull it should come back to previous activity with icon visible on header. I'm using a static image initially to hide the icon when the user comes to that particular screen. below is my login code

public void onClick(View v) {
    String password = etPassword.getText().toString();
    Intent returnIntent = new Intent();
    if(password.equals("guest")){
        returnIntent.putExtra("result", true);
        setResult(RESULT_OK, returnIntent);     
    } 
    else {
        returnIntent.putExtra("result", false);
        setResult(RESULT_OK, returnIntent);
    }

    finish();                  
}

below is my onActivityResult() code

protected void onActivityResult (int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    boolean success = data.getBooleanExtra("result", false);
    if(success) {
        sImg.setVisibility(View.VISIBLE);
    }
    else {
        sImg.setVisibility(View.INVISIBLE);
    }
}

sImg is a static image. Above code seems ok for me but not working.

4

1 回答 1

0

itz 使用下面的代码..但不确定它是否正确

if(success) {
            img = (ImageView)findViewById(R.id.redeye);
            sImg = img;
            img.setVisibility(View.VISIBLE);

    }
}}
于 2012-12-04T15:17:09.033 回答