package uz.samtuit.sammap.samapp;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;


public class HotelsActivity extends Activity {
    final Hotels[] item = new Hotels[6];
    ListView list;
    TextView tv;
    ArrayAdapter<String> adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hotels);
        item[0] = new Hotels("emirxan",123,3);
        item[1] = new Hotels("grand Samarkand",5,4);
        item[2] = new Hotels("emirxan",123,3);
        item[3] = new Hotels("grand Samarkand",5,4);
        item[4] = new Hotels("emirxan",123,3);
        item[5] = new Hotels("grand Samarkand",5,4);
        list = (ListView)findViewById(R.id.hotelsListView);
        tv=(TextView)findViewById(R.id.hotelsTitle);
        Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Baskerville.ttf");
        tv.setTypeface(tf);
        MyListAdapter adapter = new MyListAdapter(this,R.layout.list_item, item);
        list.setAdapter(adapter);
        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(HotelsActivity.this, HotelActivity.class);
                startActivity(intent);
            }
        });



    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_hotels, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

@@ -982,32 +982,1196 @@
 amarkand%22,5,4);%0A
+        %0A        //Json Parser%0A        JSONArray jhotel = null;%0A        String hotel = loadJSONFromAsset();%0A        String name = null;%0A%0A        try %7B%0A            JSONObject obj = new JSONObject(hotel);%0A%0A            jhotel = obj.getJSONArray(%22Hotel%22);%0A            // looping through All Contacts%0A            for (int i = 0; i %3C hotel.length(); i++) %7B%0A                JSONObject c = jhotel.getJSONObject(i);%0A%0A                name = c.getString(%22Name%22);%0A                String loc = c.getString(%22Location%22);%0A                String addr = c.getString(%22Address%22);%0A                String type = c.getString(%22Type%22);%0A                String price = c.getString(%22Price%22);%0A                String wi_fi = c.getString(%22Wi-Fi%22);%0A                String open = c.getString(%22Open%22);%0A                String tel = c.getString(%22Tel%22);%0A                String url = c.getString(%22URL%22);%0A                String description = c.getString(%22Description%22);%0A                String rating = c.getString(%22Rating%22);%0A                String photo = c.getString(%22Photo%22);%0A%0A            %7D%0A%0A        %7D catch (JSONException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        ///%0A        %0A        %0A
         list = (
@@ -2846,24 +2846,493 @@
 );%0A%0A%0A%0A    %7D%0A
+     public String loadJSONFromAsset() %7B%0A        String json = null;%0A        try %7B%0A%0A            InputStream is = getAssets().open(%22Hotel.json%22);%0A%0A            int size = is.available();%0A%0A            byte%5B%5D buffer = new byte%5Bsize%5D;%0A%0A            is.read(buffer);%0A%0A            is.close();%0A%0A            json = new String(buffer, %22UTF-8%22);%0A%0A%0A        %7D catch (IOException ex) %7B%0A            ex.printStackTrace();%0A            return null;%0A        %7D%0A        return json;%0A%0A    %7D%0A%0A
 %0A    @Overri

Update HotelsActivity.java