如何从MainActivity中的RecyclerView创建的所有EditTexts中检索值?
在我的RecyclerView适配器中,我正在扩展我的内部类:
public class MyPersonalAdapter extends RecyclerView.Adapter<MyPersonalAdapter.MyPersonalViewHolder>
Run Code Online (Sandbox Code Playgroud)
我在该内部类中获得了对EditText的引用:
class MyPersonalViewHolder extends RecyclerView.ViewHolder {
TextView numberTextView;
EditText nameEditText;
public MyPersonalViewHolder(View itemView) {
super(itemView);
numberTextView = (TextView) itemView.findViewById(R.id.tv_number);
nameEditText = (EditText) itemView.findViewById(R.id.et_name);
}
}
Run Code Online (Sandbox Code Playgroud)
在我想要使用的MainActivity中:
for (int i = 0; i < count; i++) {
String name = "Somehow get that name";
cv.put(MyContract.MyEntry.COLUMN_NAME, "name");
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试设置我的 choiceBox 的值。
当使用像这样的纯字符串时它可以工作:
choiceBox.getItems.setAll(FXCollections.observableArrayList("a","b","c"));
choiceBox.setValue("a");
Run Code Online (Sandbox Code Playgroud)
但当使用类填充和设置 choiceBox 时,它不会设置值(并且没有错误)
ObservableList<Course> items = FXCollections.observableArrayList();
items.add(Course.getAll());
choiceBox.getItems().setAll(items);
choiceBox.setValue(schedule.getCourse());
Run Code Online (Sandbox Code Playgroud)
也尝试使用shedule.getCourse().toString()
,因为 choiceBox 使用 toString 方法来显示课程。
需要我的对象的哪一部分ChoiceBox
?
我的课程班级:
public class Course {
// Property Value Factory
public static final String PVF_NAME = "name";
private String name;
// == constructors ==
public Course(String name) {
this.name = name;
}
// == public methods ==
@Override
public String toString() {
return name;
}
public static Course fromString(String line) {
return new Course(line);
} …
Run Code Online (Sandbox Code Playgroud)