android - pass value back to the same activity on a button click and refresh the page
I need to pass a value back to the same activity and refresh the activity to generate new data. Can anyone please provide me some ideas/guidance on how to do it? Thank you. I had try using intent to call the same activity but it doesn't work. Here is the code which i tried to use intent:
btn_next = (ImageButton) findViewById(R.id.btn_next);
btn_next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
page_counter = page_counter + 1;
if (page_counter > 1){
btn_prev.setEnabled(true);
}
Intent i = new Intent();
i.setClassName("sample.android.androidgallery","helloAndroid");
i.putExtra("page",wallpaper_page_co开发者_如何学编程unter); //to pass this activity's data to next
startActivity(i);
}
});
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putXXX(key,value);
intent.setClassName(MainActvity.this,MainActvity.class);
intent.putExtras(bundle);
startActivity(intent);
精彩评论