Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android JSON数据未出现在listview中_Android - Fatal编程技术网

Android JSON数据未出现在listview中

Android JSON数据未出现在listview中,android,Android,我一直试图用几个URL中的JSON数据填充我的ListView。问题是,它没有出现在ListView中,尽管我的LogCat清楚地显示它已经收到了数据。看看下面我的代码 XML列表视图: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layou

我一直试图用几个URL中的JSON数据填充我的ListView。问题是,它没有出现在ListView中,尽管我的LogCat清楚地显示它已经收到了数据。看看下面我的代码

XML列表视图:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<ListView

    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:drawSelectorOnTop="false"
    />
</LinearLayout>

列表视图活动:

public ListView mListView;

private static final String EventNamesURL = 
"http://eventsweb23.000webhostapp.com/JSON/EventNames.json";
private static final String EventDatesURL = 
"http://eventsweb23.000webhostapp.com/JSON/EventDates.json";
private static final String EventPlacesURL = 
"http://eventsweb23.000webhostapp.com/JSON/codebeautify.json";
private static final String EventTimesURL = 
"http://eventsweb23.000webhostapp.com/JSON/EventTimes.json";
private static final String EventURLs = 
"http://eventsweb23.000webhostapp.com/JSON/EventURLs.json";
private static final String EventImagesURL = 
"http://eventsweb23.000webhostapp.com/JSON/EventImages.json";

ArrayList<String> NameList = new ArrayList<String>();
ArrayList<String> DatesList = new ArrayList<String>();
ArrayList<String> PlacesList = new ArrayList<String>();
ArrayList<String> TimesList = new ArrayList<String>();
ArrayList<String> URLList = new ArrayList<String>();
ArrayList<String> ImagesList = new ArrayList<String>();
ArrayList<String> EventList = new ArrayList<>();

public String title;
public String place;
public String imageUrl;
public String time;
public String date;
public String url;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listview);

    Context context = this;
    mListView = (ListView) findViewById(android.R.id.list);
    EventsAdapter adapter = new EventsAdapter(context, EventList);
    mListView.setAdapter(adapter);
    adapter.notifyDataSetChanged();

    new FetchNameDataTask().execute(EventNamesURL);
    new FetchDateDataTask().execute(EventDatesURL);
    new FetchPlaceDataTask().execute(EventPlacesURL);
    new  FetchTimeDataTask().execute(EventTimesURL);
    new FetchURLDataTask().execute(EventURLs);
    new FetchImageDataTask().execute(EventImagesURL);


    setList();

    }





//Thread for fetching event names
public class FetchNameDataTask extends AsyncTask<String, Void, String> {

    @Override
    protected String doInBackground(String... params) {

        //getCookieUsingCookieHandler();

        InputStream inputStream = null;
        String result = null;
        HttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(params[0]);

        httpGet.setHeader("Content-Type", "application/json");

        try {

            HttpResponse response = client.execute(httpGet);
            inputStream = response.getEntity().getContent();


            // convert inputstream to string
            if (inputStream != null) {
                result = convertInputStreamToString(inputStream);
                Log.i("App", "Data received: " + result);

            } else
                result = "Failed to fetch data";

            return result;

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    @Override
    protected void onPostExecute(String dataFetched) {
        //parse the JSON data and then display
        parseJSONEvents(dataFetched);
    }


    private String convertInputStreamToString(InputStream inputStream) 
    throws IOException, JSONException {
        BufferedReader bufferedReader = new BufferedReader(new 
   InputStreamReader(inputStream, "UTF-8"));
        StringBuilder responseStrBuilder = new StringBuilder();
        String line = "";
        String result = "";
        while ((line = bufferedReader.readLine()) != null)
            //responseStrBuilder.append(line + "\n");
            result += line;

        inputStream.close();
        return result;

    }

    public void parseJSONEvents(String data) {

        try {
            JSONArray jsonMainNode = new JSONArray(data);

            int jsonArrLength = jsonMainNode.length();

            for (int i = 0; i < jsonArrLength; i++) {
                //listviewActivity listviewActivity1 = new 
            listviewActivity();
                JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
                title = jsonChildNode.getString("event_name");
                //NameList.add(listviewActivity.title);
                EventList.add(title);

            }


        } catch (Exception e) {
            Log.i("App", "Error parsing data: " + e.getMessage());

        }

    }


}

//Thread for fetching event dates
private class FetchDateDataTask extends AsyncTask<String, Void, String> {

    @Override
    protected String doInBackground(String... params) {

        //getCookieUsingCookieHandler();

        InputStream inputStream = null;
        String result = null;
        HttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(params[0]);

        httpGet.setHeader("Content-Type", "application/json");

        try {

            HttpResponse response = client.execute(httpGet);
            inputStream = response.getEntity().getContent();


            // convert inputstream to string
            if (inputStream != null) {
                result = convertInputStreamToString(inputStream);
                Log.i("App", "Data received: " + result);

            } else
                result = "Failed to fetch data";

            return result;

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    @Override
    protected void onPostExecute(String dataFetched) {
        //parse the JSON data and then display
        parseJSONEvents(dataFetched);
    }


    private String convertInputStreamToString(InputStream inputStream) 
    throws IOException, JSONException {
        BufferedReader bufferedReader = new BufferedReader(new 
    InputStreamReader(inputStream, "UTF-8"));
        StringBuilder responseStrBuilder = new StringBuilder();
        String line = "";
        String result = "";
        while ((line = bufferedReader.readLine()) != null)
            //responseStrBuilder.append(line + "\n");
            result += line;

        inputStream.close();
        return result;

    }

    private void parseJSONEvents(String data) {

        try {
            JSONArray jsonMainNode = new JSONArray(data);

            int jsonArrLength = jsonMainNode.length();

            for (int i = 0; i < jsonArrLength; i++) {
                //listviewActivity listviewActivity2 = new 
            listviewActivity();
                JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
                date = jsonChildNode.getString("event_date");
                //DatesList.add(listviewActivity.date);
                EventList.add(date);
            }


        } catch (Exception e) {
            Log.i("App", "Error parsing data: " + e.getMessage());

        }
    }

}

//Thread for fetching event places
private class FetchPlaceDataTask extends AsyncTask<String, Void, String> {

    @Override
    protected String doInBackground(String... params) {

        //getCookieUsingCookieHandler();

        InputStream inputStream = null;
        String result = null;
        HttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(params[0]);

        httpGet.setHeader("Content-Type", "application/json");

        try {

            HttpResponse response = client.execute(httpGet);
            inputStream = response.getEntity().getContent();


            // convert inputstream to string
            if (inputStream != null) {
                result = convertInputStreamToString(inputStream);
                Log.i("App", "Data received: " + result);

            } else
                result = "Failed to fetch data";

            return result;

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    @Override
    protected void onPostExecute(String dataFetched) {
        //parse the JSON data and then display
        parseJSONEvents(dataFetched);
    }


    private String convertInputStreamToString(InputStream inputStream) 
    throws IOException, JSONException {
        BufferedReader bufferedReader = new BufferedReader(new 
    InputStreamReader(inputStream, "UTF-8"));
        StringBuilder responseStrBuilder = new StringBuilder();
        String line = "";
        String result = "";
        while ((line = bufferedReader.readLine()) != null)
            //responseStrBuilder.append(line + "\n");
            result += line;

        inputStream.close();
        return result;

    }

    private void parseJSONEvents(String data) {

        try {
            JSONArray jsonMainNode = new JSONArray(data);

            int jsonArrLength = jsonMainNode.length();

            for (int i = 0; i < jsonArrLength; i++) {
                //listviewActivity listviewActivity3 = new listviewActivity();
                JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
                place = jsonChildNode.getString("event_place");
                //PlacesList.add(listviewActivity.place);
                EventList.add(place);
            }


        } catch (Exception e) {
            Log.i("App", "Error parsing data: " + e.getMessage());

        }
    }
}

//Thread for fetching event times
private class FetchTimeDataTask extends AsyncTask<String, Void, String> {

    @Override
    protected String doInBackground(String... params) {

        //getCookieUsingCookieHandler();

        InputStream inputStream = null;
        String result = null;
        HttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(params[0]);

        httpGet.setHeader("Content-Type", "application/json");

        try {

            HttpResponse response = client.execute(httpGet);
            inputStream = response.getEntity().getContent();


            // convert inputstream to string
            if (inputStream != null) {
                result = convertInputStreamToString(inputStream);
                Log.i("App", "Data received: " + result);

            } else
                result = "Failed to fetch data";

            return result;

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    @Override
    protected void onPostExecute(String dataFetched) {
        //parse the JSON data and then display
        parseJSONEvents(dataFetched);
    }


    private String convertInputStreamToString(InputStream inputStream) 
    throws IOException, JSONException {
        BufferedReader bufferedReader = new BufferedReader(new 
    InputStreamReader(inputStream, "UTF-8"));
        StringBuilder responseStrBuilder = new StringBuilder();
        String line = "";
        String result = "";
        while ((line = bufferedReader.readLine()) != null)
            //responseStrBuilder.append(line + "\n");
            result += line;

        inputStream.close();
        return result;

    }

    private void parseJSONEvents(String data) {

        try {
            JSONArray jsonMainNode = new JSONArray(data);

            int jsonArrLength = jsonMainNode.length();

            for (int i = 0; i < jsonArrLength; i++) {
                //listviewActivity listviewActivity4 = new 
            listviewActivity();
                JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
                time = jsonChildNode.getString("event_time");
                //TimesList.add(listviewActivity.time);
                EventList.add(time);
            }


        } catch (Exception e) {
            Log.i("App", "Error parsing data: " + e.getMessage());

        }
    }
}

//Thread for fetching event URLs
private class FetchURLDataTask extends AsyncTask<String, Void, String> {

    @Override
    protected String doInBackground(String... params) {

        //getCookieUsingCookieHandler();

        InputStream inputStream = null;
        String result = null;
        HttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(params[0]);

        httpGet.setHeader("Content-Type", "application/json");

        try {

            HttpResponse response = client.execute(httpGet);
            inputStream = response.getEntity().getContent();


            // convert inputstream to string
            if (inputStream != null) {
                result = convertInputStreamToString(inputStream);
                Log.i("App", "Data received: " + result);

            } else
                result = "Failed to fetch data";

            return result;

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    @Override
    protected void onPostExecute(String dataFetched) {
        //parse the JSON data and then display
        parseJSONEvents(dataFetched);
    }


    private String convertInputStreamToString(InputStream inputStream) 
    throws IOException, JSONException {
        BufferedReader bufferedReader = new BufferedReader(new 
    InputStreamReader(inputStream, "UTF-8"));
        StringBuilder responseStrBuilder = new StringBuilder();
        String line = "";
        String result = "";
        while ((line = bufferedReader.readLine()) != null)
            //responseStrBuilder.append(line + "\n");
            result += line;

        inputStream.close();
        return result;

    }

    private void parseJSONEvents(String data) {

        try {
            JSONArray jsonMainNode = new JSONArray(data);

            int jsonArrLength = jsonMainNode.length();

            for (int i = 0; i < jsonArrLength; i++) {
                //listviewActivity listviewActivity5 = new 
            listviewActivity();
                JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
                url = jsonChildNode.getString("event_url");
                //URLList.add(listviewActivity.url);
                EventList.add(url);
            }


        } catch (Exception e) {
            Log.i("App", "Error parsing data: " + e.getMessage());

        }
    }
}

//Thread for fecthing event image URLs
private class FetchImageDataTask extends AsyncTask<String, Void, String> {

    @Override
    protected String doInBackground(String... params) {

        //getCookieUsingCookieHandler();

        InputStream inputStream = null;
        String result = null;
        HttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(params[0]);

        httpGet.setHeader("Content-Type", "application/json");

        try {

            HttpResponse response = client.execute(httpGet);
            inputStream = response.getEntity().getContent();


            // convert inputstream to string
            if (inputStream != null) {
                result = convertInputStreamToString(inputStream);
                Log.i("App", "Data received: " + result);

            } else
                result = "Failed to fetch data";

            return result;

        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    @Override
    protected void onPostExecute(String dataFetched) {
        //parse the JSON data and then display
        parseJSONEvents(dataFetched);
    }


    private String convertInputStreamToString(InputStream inputStream) 
    throws IOException, JSONException {
        BufferedReader bufferedReader = new BufferedReader(new 
    InputStreamReader(inputStream, "UTF-8"));
        StringBuilder responseStrBuilder = new StringBuilder();
        String line = "";
        String result = "";
        while ((line = bufferedReader.readLine()) != null)
            //responseStrBuilder.append(line + "\n");
            result += line;

        inputStream.close();
        return result;

    }

    private void parseJSONEvents(String data) {

        try {
            JSONArray jsonMainNode = new JSONArray(data);

            int jsonArrLength = jsonMainNode.length();

            for (int i = 0; i < jsonArrLength; i++) {
                //listviewActivity listviewActivity6 = new 
            listviewActivity();
                JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
                imageUrl = jsonChildNode.getString("img_url");
                //ImagesList.add(listviewActivity.imageUrl);
                EventList.add(imageUrl);
            }


        } catch (Exception e) {
            Log.i("App", "Error parsing data: " + e.getMessage());

        }


    }
}

public ArrayList getArrayList(){
    return EventList;
}

public void setList() {

    //final ArrayList<listviewActivity> List =  getArrayList();

    String[] listItems = new String[EventList.size()];

    for (int i = 0; i < EventList.size(); i++) {
        EventList.get(i);
        listItems[i] = title;
    }



    final Context context = this;
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int 
      position, long id) {

            //1
            EventList.get(position);

            //2
            Intent detailIntent = new Intent(context, event_detail.class);

            //3
            detailIntent.putExtra("title", title);
            detailIntent.putExtra("url", url);

            //4
            startActivity(detailIntent);
        }

    });
public class EventsAdapter extends BaseAdapter{

LayoutInflater minflater;
Context mcontext;
ArrayList<String> mDataSource;



public EventsAdapter(Context context, ArrayList<String> items){
    mcontext = context;
    mDataSource = items;
    minflater = (LayoutInflater) 
mcontext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

}

@Override
public int getCount() {
    return mDataSource.size();
}

@Override
public Object getItem(int position) {
    return mDataSource.get(position);

}

@Override
public long getItemId(int position) {
    return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    //Get view for row item
    View rowView = minflater.inflate(R.layout.list_item_event, parent, 
false);

    //Get the title element
    TextView titleTextView = (TextView) 
rowView.findViewById(R.id.event_list_title);

    //Get the date element
    TextView dateTextView = (TextView) 
rowView.findViewById(R.id.event_list_date);

    //Get the time element
    TextView timeTextView = (TextView) 
rowView.findViewById(R.id.event_list_time);

    //Get the time element
    TextView placeTextView = (TextView) 
rowView.findViewById(R.id.event_list_place);

    //Get the thumbnail element
    ImageView thumbnailImageView = (ImageView) 
rowView.findViewById(R.id.event_list_thumbnail);

    //1
    listviewActivity listviewActivity = (listviewActivity) 
getItem(position);

    //2
    titleTextView.setText(listviewActivity.title);
    dateTextView.setText(listviewActivity.date);
    timeTextView.setText(listviewActivity.time);
    placeTextView.setText(listviewActivity.place);

    //3

Picasso.with(mcontext)
.load(listviewActivity.imageUrl)
.placeholder(R.mipmap.ic_launcher)
.resize(250,250).centerCrop().into(thumbnailImageView);

return rowView;
  }
}
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
    android:id="@+id/event_list_thumbnail"
    android:layout_width="90dp"
    android:layout_height="90dp"
    android:layout_alignParentStart="true"
    android:layout_centerVertical="true"
    android:layout_marginBottom="6dp"
    android:layout_marginStart="4dp"
    android:layout_marginTop="6dp"
    android:scaleType="centerInside"
    tools:src="@mipmap/ic_launcher"
    android:layout_marginLeft="4dp"
    android:layout_alignParentLeft="true" />


<RelativeLayout
    android:id="@+id/recipe_list_text_layout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_toEndOf="@id/event_list_thumbnail"
    android:layout_toRightOf="@id/event_list_thumbnail">

    <TextView
        android:id="@+id/event_list_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:textSize="18sp"
        tools:text="Event Name"
        />

    <TextView
        android:id="@+id/event_list_date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/event_list_title"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="2dp"
        android:ellipsize="end"
        android:maxLines="3"
        android:textSize="16sp"
        tools:text="Date"
        />

    <TextView
        android:id="@+id/event_list_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/event_list_date"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="2dp"
        android:ellipsize="end"
        android:maxLines="3"
        android:textSize="16sp"
        tools:text="Time"
        />

    <TextView
        android:id="@+id/event_list_place"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/event_list_time"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:layout_marginTop="2dp"
        android:ellipsize="end"
        android:maxLines="3"
        android:textSize="16sp"
        tools:text="Place"
        />

   </RelativeLayout>
</RelativeLayout>
公共列表视图mListView;
私有静态最终字符串EventNamesURL=
"http://eventsweb23.000webhostapp.com/JSON/EventNames.json";
私有静态最终字符串EventDatesURL=
"http://eventsweb23.000webhostapp.com/JSON/EventDates.json";
私有静态最终字符串EventPlacesURL=
"http://eventsweb23.000webhostapp.com/JSON/codebeautify.json";
私有静态最终字符串EventTimesURL=
"http://eventsweb23.000webhostapp.com/JSON/EventTimes.json";
私有静态最终字符串EventURLs=
"http://eventsweb23.000webhostapp.com/JSON/EventURLs.json";
私有静态最终字符串EventImagesURL=
"http://eventsweb23.000webhostapp.com/JSON/EventImages.json";
ArrayList NameList=新的ArrayList();
ArrayList DatesList=新的ArrayList();
ArrayList PlacesList=新的ArrayList();
ArrayList TimesList=新建ArrayList();
ArrayList URLList=新的ArrayList();
ArrayList ImagesList=新的ArrayList();
ArrayList EventList=新建ArrayList();
公共字符串标题;
公共场所;
公共字符串imageUrl;
公共字符串时间;
公共字符串日期;
公共字符串url;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u列表视图);
上下文=这个;
mListView=(ListView)findViewById(android.R.id.list);
EventsAdapter=新的EventsAdapter(上下文,EventList);
mListView.setAdapter(适配器);
adapter.notifyDataSetChanged();
新建FetchNameDataTask().execute(EventNamesURL);
新建FetchDateDataTask().execute(EventDatesURL);
新建FetchPlaceDataTask().execute(EventPlacesURL);
新建FetchTimeDataTask().execute(EventTimesURL);
新建FetchURLDataTask().execute(EventURLs);
新建FetchImageDataTask().execute(EventImagesURL);
setList();
}
//获取事件名称的线程
公共类FetchNameDataTask扩展了AsyncTask{
@凌驾
受保护的字符串doInBackground(字符串…参数){
//getCookieUsingCookieHandler();
InputStream InputStream=null;
字符串结果=null;
HttpClient=new DefaultHttpClient();
HttpGet HttpGet=新的HttpGet(参数[0]);
setHeader(“内容类型”、“应用程序/json”);
试一试{
HttpResponse response=client.execute(httpGet);
inputStream=response.getEntity().getContent();
//将inputstream转换为字符串
如果(inputStream!=null){
结果=convertInputStreamToString(inputStream);
Log.i(“应用程序”,“收到的数据:+结果”);
}否则
result=“无法获取数据”;
返回结果;
}捕获(客户端协议例外e){
e、 printStackTrace();
}捕获(IOE异常){
e、 printStackTrace();
}捕获(JSONException e){
e、 printStackTrace();
}
返回null;
}
@凌驾
受保护的void onPostExecute(获取字符串数据){
//解析JSON数据,然后显示
parseJSONEvents(数据获取);
}
私有字符串转换器InputStreamToString(InputStream InputStream)
抛出IOException、JSONException{
BufferedReader BufferedReader=新的BufferedReader(新的
InputStreamReader(inputStream,“UTF-8”);
StringBuilder responsestBuilder=新建StringBuilder();
字符串行=”;
字符串结果=”;
而((line=bufferedReader.readLine())!=null)
//responsestBuilder.append(行+“\n”);
结果+=行;
inputStream.close();
返回结果;
}
公共void parseJSONEvents(字符串数据){
试一试{
JSONArray jsonMainNode=新的JSONArray(数据);
int jsonArrLength=jsonMainNode.length();
for(int i=0;i //DatesList.add(listviewActivity.date);
 public void parseJSONEvents(String data) {

    try {
        JSONArray jsonMainNode = new JSONArray(data);

        int jsonArrLength = jsonMainNode.length();

        for (int i = 0; i < jsonArrLength; i++) {
            //listviewActivity listviewActivity1 = new 
        listviewActivity();
            JSONObject jsonChildNode = jsonMainNode.getJSONObject(i);
            title = jsonChildNode.getString("event_name");
            //NameList.add(listviewActivity.title);
            EventList.add(title);

        }
adapter.notifyDataSetChanged();

    } catch (Exception e) {
        Log.i("App", "Error parsing data: " + e.getMessage());

    }

}
 /*   listviewActivity listviewActivity = (listviewActivity) 
    getItem(position);

    //2
    titleTextView.setText(listviewActivity.title);
    dateTextView.setText(listviewActivity.date);
    timeTextView.setText(listviewActivity.time);
    placeTextView.setText(listviewActivity.place);

    //3

Picasso.with(mcontext)
.load(listviewActivity.imageUrl)
.placeholder(R.mipmap.ic_launcher)
.resize(250,250).centerCrop().into(thumbnailImageView); */
titleTextView.setText(mDataSource.get(position));