1. Are you ready for the Galaxy S20? Here is everything we know so far!

Help creating a social network layout

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

  1. cdubs

    cdubs Newbie
    Thread Starter

    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.
     


Loading...
Similar Threads - Help creating social
  1. Protonus
    Replies:
    1
    Views:
    198
  2. Nitsuga
    Replies:
    16
    Views:
    200
  3. TsubasaChronix
    Replies:
    0
    Views:
    204
  4. VedantS
    Replies:
    1
    Views:
    181
  5. Ajaykumar Panchamoorthy
    Replies:
    2
    Views:
    157
  6. timmothey
    Replies:
    0
    Views:
    379
  7. Alexandros81
    Replies:
    21
    Views:
    2,924
  8. jscotts
    Replies:
    6
    Views:
    17,275
  9. mikeyeaah
    Replies:
    0
    Views:
    405

Share This Page

Loading...