onCreateJava生命周期中的view方法如何调用?
How do I call the view method in the onCreate Java lifecycle?
当我想使用 setText 时遇到问题,但是当它直接在 onCreate 上调用时却不能?
这是我的方法:
public void onSendData(View view) {
long seek = videoView.getCurrentPosition();
WritableMap args = Arguments.createMap();
args.putInt("index", index);
args.putInt("seek", (int) seek);
args.putString("type", "paused");
args.putString("name", playingVideo.getString("name"));
args.putString("category_name", playingVideo.getString("category_name"));
args.putString("date", playingVideo.getString("date"));
sendEvent(reactContext, "onSendData", args);
textName.setText(playingVideo.getString("name") + " " + playingVideo.getString("category_name"));
textDate.setText(playingVideo.getString("date"));
textCustomerName.setText(playingVideo.getString("customer_name"));
textEstimate.setText(playingVideo.getString("estimate"));
textPaid.setText(playingVideo.getString("paid"));
textPrice.setText(playingVideo.getString("price"));
textAddress.setText(playingVideo.getString("address"));
textLongAddress.setText(playingVideo.getString("long_address"));
}
这是我调用 onCreate 生命周期时的代码:
public void onCreate() {
super.onCreate();
onSendData();
........
.....
}
请帮忙,非常感谢。
不确定到底是什么问题,但我会这样做:
public void onCreate() {
super.onCreate();
loadViews(); //create instance of view objects textName, textDate, etc.
onSendData(null); //passing View as null
........
.....
}
当我想使用 setText 时遇到问题,但是当它直接在 onCreate 上调用时却不能?
这是我的方法:
public void onSendData(View view) {
long seek = videoView.getCurrentPosition();
WritableMap args = Arguments.createMap();
args.putInt("index", index);
args.putInt("seek", (int) seek);
args.putString("type", "paused");
args.putString("name", playingVideo.getString("name"));
args.putString("category_name", playingVideo.getString("category_name"));
args.putString("date", playingVideo.getString("date"));
sendEvent(reactContext, "onSendData", args);
textName.setText(playingVideo.getString("name") + " " + playingVideo.getString("category_name"));
textDate.setText(playingVideo.getString("date"));
textCustomerName.setText(playingVideo.getString("customer_name"));
textEstimate.setText(playingVideo.getString("estimate"));
textPaid.setText(playingVideo.getString("paid"));
textPrice.setText(playingVideo.getString("price"));
textAddress.setText(playingVideo.getString("address"));
textLongAddress.setText(playingVideo.getString("long_address"));
}
这是我调用 onCreate 生命周期时的代码:
public void onCreate() {
super.onCreate();
onSendData();
........
.....
}
请帮忙,非常感谢。
不确定到底是什么问题,但我会这样做:
public void onCreate() {
super.onCreate();
loadViews(); //create instance of view objects textName, textDate, etc.
onSendData(null); //passing View as null
........
.....
}