我已经成功地将一个值从一个静态类传递给一个非静态类,但是当我将该值放入一个EditText
.
public class HelloBubblesActivity extends SherlockFragmentActivity {
public EditText editText1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_discuss);
editText1 = (EditText) findViewById(R.id.editText1);
}
public static class MyDialogFragment extends SherlockDialogFragment {
//i fill variable emotx is "test string"
public void emot(String emotx){
HelloBubblesActivity hb=new HelloBubblesActivity();
hb.smiley(emotx); //send value to smiley method..
}
}
public void smiley(String name){
Log.d("test", name); //result value is "test string" (success)
editText1.setText(name); //here is error
}
}
我不确定我为什么会遇到这个问题。谁能明白为什么这没有达到预期的效果?