Verständnis JSON
This commit is contained in:
parent
a3a1ceae59
commit
5407dc0f5b
@ -14,8 +14,13 @@ import androidx.fragment.app.Fragment;
|
|||||||
import com.android.volley.Response;
|
import com.android.volley.Response;
|
||||||
import com.example.aped.MainActivity;
|
import com.example.aped.MainActivity;
|
||||||
import com.example.aped.R;
|
import com.example.aped.R;
|
||||||
|
|
||||||
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.Dictionary;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class AllIOsFragment extends Fragment {
|
public class AllIOsFragment extends Fragment {
|
||||||
/**
|
/**
|
||||||
@ -139,7 +144,25 @@ public class AllIOsFragment extends Fragment {
|
|||||||
get(i), new Response.Listener<JSONObject>() {
|
get(i), new Response.Listener<JSONObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(final JSONObject response) {
|
public void onResponse(final JSONObject response) {
|
||||||
textViewState.setText(response.toString());
|
try {
|
||||||
|
JSONObject pins = response.getJSONObject("state");
|
||||||
|
String devicename = mainActivity.xml.getDeviceNames().get(i);
|
||||||
|
Dictionary<String,Object> portinfo = mainActivity.xml.getPort(devicename);
|
||||||
|
List<String> pinnames = (List<String>) portinfo.get("pins");
|
||||||
|
String firstpinname = pinnames.get(0);
|
||||||
|
int groesse = pinnames.size();
|
||||||
|
/** for(String pinname : pinnames){
|
||||||
|
|
||||||
|
}//anstatt for mit laufvariable
|
||||||
|
for(int h; h < pinnames.size();h++){
|
||||||
|
String pinname = pinnames.get(h);
|
||||||
|
}*/
|
||||||
|
String firstpinvalue = pins.getString(firstpinname);
|
||||||
|
textViewState.setText(firstpinvalue);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
buttonViewFavoriten.setImageResource(favoriteImage);
|
buttonViewFavoriten.setImageResource(favoriteImage);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user