我的方法是:
textViewForWelcomeMessage = (TextView)
findViewById(R.id.textViewToDisplayMessageForWelcomePage);
imageViewPhoto = (ImageView) findViewById(R.id.imageViewPhotoForWelcomePage);
if(textViewForWelcomeMessage.getText().length()==0) {
textViewForWelcomeMessage.setText("You are not yet setup,
Let us get you configured"); // textViewForWelcomeMessage has value
textViewForWelcomeMessage.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent intentForSettingsPage = new Intent(
WelcomPageActivity.this,
SettingsActitivity.class);
startActivity(intentForSettingsPage);
}
});
flag++;
}
if(flag > 0) {
DatabaseManager db = new DatabaseManager(WelcomPageActivity.this);
parentInfoDetails = db.getAllParentDetails();
for (Parent parentData : parentInfoDetails) {
image = parentData.getImage();
}
imageStream = new ByteArrayInputStream(image);
theImage = BitmapFactory.decodeStream(imageStream);
imageViewPhoto.setImageBitmap(theImage);
childrenInfoDetails = db.getAllChildrenDetails();
for (Student stu : childrenInfoDetails) {
studFirstName = stu.getStudent_firstname();
}
textViewForWelcomeMessage.setText("Hugs to little "
+ studFirstName + " from mommy and daddy");
}