【发布时间】:2018-08-02 00:26:31
【问题描述】:
我有一个包含游戏标题的NumberPicker。
问题是我希望每次有人滚动NumberPicker 并停在其中一个标题上时,我将能够立即处理此操作并用我想要的信息填写 2 EditText。
在按钮按下时,每次在视图上按下Button 时都会处理void onClick(View view),我如何使用NumberPicker 做类似的事情?
这是我的代码:
NumberPicker picker;
SharedPreferences sp;
String JsonDataGL;
String[] arrayGL;
ProgressDialog p;
GamesLibrary[] gamesArray;
String Count = "0";
EditText gameTitleET, gameContentET;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_post);
sp=getSharedPreferences("JsonData", 0);
JsonDataGL = sp.getString("JsonGL", null);
gameTitleET = findViewById(R.id.GameTitleET); //The 2 EditTexts I want to fill with text
gameContentET = findViewById(R.id.GameTitleET);
JSONObject json_data = null;
try {
json_data = new JSONObject(JsonDataGL);
} catch (JSONException e) {
e.printStackTrace();
}
try {
Count = json_data.getString("count");
Log.d("Nugi32", Count);
} catch (JSONException e) {
e.printStackTrace();
}
gamesArray = new GamesLibrary[Integer.parseInt(Count)];
picker = (NumberPicker) findViewById(R.id.numberPicker2);
picker.setMinValue(0);
picker.setMaxValue(Integer.parseInt(Count)-1);
arrayGL = new String[Integer.parseInt(Count)];
DownLoadJsonGL downLoadJsonGL = new DownLoadJsonGL();
downLoadJsonGL.execute(JsonDataGL); //Here The NumberPicker is filled with the titles
}
你知道我该怎么做吗?或引导我在线教程? 因为我在网上找不到与此主题相关的任何问题。 谢谢!
【问题讨论】:
-
您必须为此创建自己的号码选择器。
-
什么意思?
-
好的,看来@ZeekHuge 有办法回答
标签: java android numberpicker