用齐射分析杰森,它没有回应

时间:2019-06-08 19:31:09

标签: android json

我正在尝试获取片段上的json数据。但这没有反应。代码或日志上没有错误。我做一个列表,但实际上,每个数组下都有一个数据。这是json文件的link。我不知道我想念什么。我试着赶上日志和吐司,但结果还是一样。谢谢您的帮助。

public class BlankFragment extends Fragment implements View.OnClickListener{


String oran;
TextView macbeles2text;
TextView macbeles2oran;


TextView macbeles2saat;
TextView macbeles2tahmin;






Button gecbaken;


String Bsmaclar = "http://myjson.com/8fvtp";
RequestQueue mac2sorgu;/*Sonuc rakamlar icin*/
ArrayList<String> mac2array;




public BlankFragment() {
    // Required empty public constructor
}


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View myview = inflater.inflate(R.layout.fragment_blank, container, false);






    macbeles2text = myview.findViewById(R.id.maçbeles2text);
    macbeles2oran = myview.findViewById(R.id.maçbeles2oran);



    macbeles2saat = myview.findViewById(R.id.maçbeles2saat);
    macbeles2tahmin = myview.findViewById(R.id.maçbeles2tahmin);




    mac2sorgu = Volley.newRequestQueue(getActivity().getApplicationContext());

    mac2array = new ArrayList<>();

    JsonObjectRequest getmac2 = new JsonObjectRequest(Request.Method.GET, Bsmaclar, null,
            new Response.Listener<JSONObject>()
            {
                @Override
                public void onResponse(JSONObject response) {
                    try {
                        JSONArray arrYazilar= response.getJSONArray("Musabaka2");
                        for (int i = 0; i < arrYazilar.length(); i++){
                            JSONObject Musabaka2 = arrYazilar.getJSONObject(i);
                            String Tarihmus2 = Musabaka2.getString("NewZaman");
                            String Oynayanmus2 = Musabaka2.getString("Oynayanlar");
                            String Tahminen2 = Musabaka2.getString("Tahmin");
                            String Tahmintrmus2 = Musabaka2.getString("Tahmin2");
                            String Oranmus2 = Musabaka2.getString("Oran");


                            Toast.makeText(getActivity(), "Budur"+Tarihmus2, Toast.LENGTH_SHORT).show();

                            mac2array.add(Tarihmus2);
                            Toast.makeText(getActivity(), "Budur"+Tarihmus2, Toast.LENGTH_SHORT).show();



                            macbeles2text.setText(Oynayanmus2);
                            macbeles2saat.setText(Tarihmus2);
                            macbeles2tahmin.setText(Tahminen2);
                            macbeles2oran.setText(Oranmus2);




                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                }
            },
            new Response.ErrorListener()
            {
                @Override
                public void onErrorResponse(VolleyError error) {
                    //Log.d("Error.Response", error.getMessage());
                }
            }
    );




    mac2sorgu.add(getmac2);
    return myview;
}




public void onClick(View view) {
    BlankFragment3 fragment3 = new BlankFragment3();
    FragmentManager fragmentManager = getFragmentManager();
    FragmentTransaction fragmentTransaction =        fragmentManager.beginTransaction();
    fragmentTransaction.replace(R.id.container, fragment3);
    fragmentTransaction.addToBackStack(null);
    fragmentTransaction.commit();
}



}

0 个答案:

没有答案