Few details about my code:
I get a JSONObject
, then I get the strings from it and using the field "name"
, I create as many buttons
as fields
are there in the json
.
Now, the thing is I want to add functionality to the buttons
too and I am not sure if it will work this way.
Check my code please, I ll comment where I am stuck.
for(int i=0; i<arr.length();i++){
JSONObject oneObject = arr.getJSONObject(i);
id = oneObject.getString("Id");
nume = oneObject.getString("Nume");
Button btn = new Button(context);
btn.setId(i);
btn.setText(nume);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//STUCK HERE!
}
});
ll.addView(btn);
}
So, for each button
, I want to make a new activity, so a new intent
, because each button
will need a new "screen"
(or so to say).
Is there any ways I can actually do this ,or it's impossible?
NOTE: I could not find anything like this over the internet and my thoughts on this is that it's impossible, but I wanted a few more opinions before I move on.