1. Download our Official Android App: Forums for Android!

Apps Help creating a social network layout

Discussion in 'Android Development' started by cdubs, Apr 6, 2016.

  1. cdubs

    cdubs Newbie
    Thread Starter
    Rank:
    None
    Points:
    16
    Posts:
    13
    Joined:
    Feb 25, 2016

    Feb 25, 2016
    13
    1
    16
    Male
    I am creating a simple social network. I am really having trouble on creating a layout to put all the content that a user posts. I am trying to use some type of grid layout or something to display all the posts. Right now I am getting all my information from two arraylists. One arraylist contains the content, the other contains the username that belongs to each post. How can I put these into a nice layout that contains the content with the username under it? Here is what I am doing so far:

    private void popPosts(JSONArray jsonArray){
    //go through items in array
    for(int i = 0; i < jsonArray.length(); i++) {
    try {
    //get json object
    JSONObject json = jsonArray.getJSONObject(i);

    //add topic to arraylist
    //System.out.println(posts);
    contentPosts.add(json.getString(Config.post_content));
    userPosts.add(json.getString(Config.post_user));
    System.out.println(contentPosts);
    System.out.println(userPosts);
    } catch (JSONException e) {

    }
    }
    gridView = (GridView) findViewById(R.id.gridView);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
    android.R.layout.simple_list_item_1, contentPosts);
    gridView.setAdapter(adapter);
    }

    Right now I am just posting the content array not the user. I do not know how to combine them.
     

    Advertisement

Share This Page

Loading...