我想使用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
........
.....
}