-5

When I enter the database url, I got error Unreachable Statement

String url= "http://www.example.com/php.php";

This is my code:

        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
            View view = inflater.inflate(R.layout.tab_2,container,false);
            return view;


            String url= "http://www.example.com";

            warga = (RecyclerView) view.findViewById(R.id.warga);
            LinearLayoutManager llm = new LinearLayoutManager(getActivity());
            llm.setOrientation(LinearLayoutManager.VERTICAL);
            warga.setLayoutManager(llm);

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

            list_data = new ArrayList<HashMap<String, String>>();

            stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Log.d("response ", response);
                    try {
                        JSONObject jsonObject = new JSONObject(response);
                        JSONArray jsonArray = jsonObject.getJSONArray("warga");
gprathour
  • 14,813
  • 5
  • 66
  • 90

3 Answers3

2

return view; code is not executed after return. That's all. return should be very last thing you do in your method. Nothing can be done after return
this is Java very-basics.

Vladyslav Matviienko
  • 10,610
  • 4
  • 33
  • 52
0

Everything written after return view will not be executed.

You need to write your code before return statement.

gprathour
  • 14,813
  • 5
  • 66
  • 90
-1

move this return view; from the second line of method to the last line of method

Shubham Goel
  • 1,962
  • 17
  • 25