its right you cant cast ArrayList to CharSequence direct like this -
jagdish
Sep 21 '16 11:46
String list=new String();//placed
//removed ArrayList<String> list = new ArrayList<String>();
JSONArray jsona = new JSONArray(result);
for(int i=0; i < jsona.length(); i++){
JSONObject jsonObject= jsona.getJSONObject(i);
int userid= Integer.parseInt(jsonObject.optString("userid"));
String username= jsonObject.optString("username").toString();
// changed here : simply append to string
list+=userid+":"+username;
//remvoed list.add(pair);
}
Toast.makeText(getBaseContext(),(CharSequence) list, Toast.LENGTH_LONG).show();