根据我的论文,我在LogCat中发出警告,我认为这可能会影响我的代码.
我收到一个包含一些数据的JSON,我必须以编程方式使用checkbox和radiobutton(在RadioGroup中)进行布局.后来我可以投票这个调查,这是我的问题因为我在我的布局中getChildAt()
if(child instanceof CheckBox)
Run Code Online (Sandbox Code Playgroud)
不起作用,我不明白为什么.
这是我的代码:
ll = (LinearLayout) findViewById(R.id.llSurvey); //OnCreate
/*Creating CheckBox*/
String votes = jObj.getString("votes");
String label = jObj.getString("label");
String usid = jObj.getString("USID");
if(uType.equals("multi")){
CheckBox cb = new CheckBox(SingleSurvey.this);
cb.setText(label + " (" + votes + ")");
cb.setId(s+1000);
ll.addView(cb);
Log.i("MULTI_TYPE", "usid: " + usid + " id: " + cb.getId());
}
s++;
/*Voting*/
for(int i = 0; i < ll.getChildCount(); i++){
View child = ll.getChildAt(i);
int p = child.getId();
Log.i("CHILD ID", "id: " + p);
if(child instanceof …Run Code Online (Sandbox Code Playgroud)