Q:

How can I setText on Button array in Looping on Fragment?

I want to setText on Button, with the text I get from json parse, and set it into Button Array. I wonder to set via looping. Can anyone help me?
for(int i = 0; i < jumlah_table; i++) {
    JSONObject object = jsonArray.getJSONObject(i);
    final  String nama[] = new String[jumlah_table];
    nama[i] = object.getString("table_name");
    getActivity().runOnUiThread(new Runnable() {
        @Override
        public void run() {
            int j = 0;
            buttons[j].setText(nama[j]);
            j++;
        }
    });
}

Thanks for your help.

A:

try this: initialize your array outside:
final  String nama[] = new String[jumlah_table];

Now in Asynch task onPostExecute use the following code;
  for (int i = 0; i < jumlah_table; i++) {
    JSONObject object = jsonArray.getJSONObject(i);
    nama[i] = object.getString("table_name");
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    Button btn = new Button(this);
    btn.setId(i);
    final int id_ = btn.getId();
    btn.setText(nama[i]);
    linear.addView(btn, params);
}

where 
LinearLayout linear = (LinearLayout)findViewById(R.id.your_layout);

