アクティビティ:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cool); //layout with button and custom view
myNewView myView = new myNewView(this); // create custom view
button = (Button) findViewById(R.id.btn_1);
button.setOnClickListener(new OnClickListener() {
public void onClick(View view) {
String t = myView.do_smth(); ///HERE is NOT working
}
});
}
カスタム ビュー:
public class myNewView extends View {
public myNewView(Context context) {
super(context);
initialize();
}
public String do_smth() {
String t = "";
t = "34";
return t;
}
}
したがって、t 変数は空です。このコードの何が問題になっていますか? 詳細を知りたい場合はお知らせください。