Reputation: 1041
I have an Activity. In that Activity i have one Custom Dialog.In that dialog one button is there.on click of that button i want to change the color of a text which i have in my activity.how to acheive that. can anyone please help me. My code ---
public class Test extends Activity{
TextView tv;
Button b;
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
tv = (TextView)tv.findViewById(R.id.tv1);
button initialization code..
b.setOnclickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
popup();
}
}
public void popup(final int position)
{
final Dialog dialog = new Dialog(Test.this);
TextView view
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.popup);
view = (TextView) dialog.findViewById(R.id.view1);
view .setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
toast msg...
}
});
}
Upvotes: 2
Views: 1253
Reputation: 45062
public void popup() {
final Dialog dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.popup);
dialog.findViewById(R.id.textView1).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// remove dialog
dialog.dismiss();
// change color of text
((TextView) findViewById(R.id.change_my_color)).setTextColor(Color.GREEN);
}
});
dialog.show();
}
Upvotes: 1