In which container can I collect Strings to show any of them

vendettacore

I have a LinkedHashMap which fills with data from db with loop "for" string by string and when I try to show the first or the last String, the method can show me only the last String in log. But in application listViewContent is filled fully. So I don't understand why I can't see any string that I want. I need to collect all strings I get from db and compare them in future.

How can I collect all strings and what method should I call to show the string I want to see?Unfortunately I can only retrieve one (and the last instead of the first) string. Here is my example code :

protected void onCreate(Bundle saveInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    FirstMethod();
}

public FirstMethod() {
    SecondMethod newMethod = .. // getting data from the second method
}

public SecondMethod() {
    public void onResponseReceived(String result) {
        try {
            ...
            if (posts != null) {
                for (WallPostItem post : posts) {    // this loop
                    //create new map for a post
                    Map<String, Object> map = new LinkedHashMap<String, Object>();
                    map.put(ATTRIBUTE_NAME_TEXT, post.text);
                    PictureItem postPicture = new PictureItem();
                    map.put(ATTRIBUTE_NAME_IMAGE, postPicture);
                    map.put(ATTRIBUTE_NAME_DATE, post.date);
                    sAdapter.notifyDataSetChanged();
                };
            };
            ...
            List<Map.Entry<String, Object>> list = new ArrayList<Map.Entry<String, Object>>(GlobalMap.entrySet());
            Map.Entry<String, Object> firstInsertedEntry = list.get(0);
            Log.w("FirstEntryOfMap",""+firstInsertedEntry);   // this log shows me the last string instead of the first
        }
        if (isRefresh) {
            isRefresh = false;
            lvSimple.setSelectionAfterHeaderView();
        }
        } catch (Exception e) {
            Log.d("exceptions", "problem in get wall post task after post execute: " + e.toString());
        }
    }
Elliott Frisch

You aren't putting your values into a List, you are putting them into a Map (that preserves key order). I would suggest you create a POJO class,

class MyAttribute {
  final String postName;
  final PictureItem postPicture;
  final Date postDate;
  public MyAttribute(String postName, PictureItem postPicture, Date postDate) {
    this.postName = postName;
    this.postPicture = postPicture;
    this.postDate = postDate;
  }

  public String getPostName() {
    return postName;
  }
  public Date getPostDate() {
    return postDate;
  }
  public PictureItem getPostPicture() {
    return postPicture;
  }
}

Then you could create a

List<MyAttribute> myAttributes = new ArrayList<>();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I add strings and print them?

From Java

How can I collect an istream_view into a container?

From Dev

How can I get any row which substring is any?

From Dev

How can I filter out strings that contain no numbers within them?

From Dev

How can I concatenate strings and use them as a list name?

From Dev

How can I store strings with variables in them in another Java class?

From Dev

How can i only show the header on some pages and not all of them

From Dev

How can I rotate the elements and only show 4 of them?

From Dev

Am I missing any kernel files? If so, which ones and how should I install them?

From Dev

Is there any logical container tag in HTMl that I can use for grouping?

From Dev

How can I make a macro work on any container?

From Dev

Internet vs. telephone cable. How can I tell them apart? Which of them is this one?

From Dev

How can I hide/show a div-container in JavaScript?

From Dev

How can I show only the allocated resources in Docker container?

From Dev

Building a poker probabilities calculator - how can I collect data about objects which keep getting deleted and recreated?

From Dev

How can I know which element in a list triggered an any() function?

From Dev

How can I know which element in a list triggered an any() function?

From Dev

When a user clicks, how can I collect the x/y as well as any link that may have been clicked?

From Dev

How can i add a dialog which will show a particular file details?

From Dev

How can i show the results which as multiple values in the column in SQL

From Dev

Can I show strings on ncurses screen without getch() function?

From Dev

Is there any way I can get all of the functions of a module so I can call them?

From Dev

why the view pager show the last image of an array each time i select any image of them?

From Dev

Restangular / Json-ld | I can get the data, but I can't show them

From Dev

How can I show any object as string in JavaScript?

From Dev

iTextSharp Table: do I need to DIM any cell or column or can I reuse them?

From Dev

Are there any multiformat image viewers, which are similar to feh and can show SVG files?

From Dev

How can I get only the specific H3 I am hovering over to show and not all of them?

From Dev

How can I create Views in xml which I can use for any layout?

Related Related

  1. 1

    How can I add strings and print them?

  2. 2

    How can I collect an istream_view into a container?

  3. 3

    How can I get any row which substring is any?

  4. 4

    How can I filter out strings that contain no numbers within them?

  5. 5

    How can I concatenate strings and use them as a list name?

  6. 6

    How can I store strings with variables in them in another Java class?

  7. 7

    How can i only show the header on some pages and not all of them

  8. 8

    How can I rotate the elements and only show 4 of them?

  9. 9

    Am I missing any kernel files? If so, which ones and how should I install them?

  10. 10

    Is there any logical container tag in HTMl that I can use for grouping?

  11. 11

    How can I make a macro work on any container?

  12. 12

    Internet vs. telephone cable. How can I tell them apart? Which of them is this one?

  13. 13

    How can I hide/show a div-container in JavaScript?

  14. 14

    How can I show only the allocated resources in Docker container?

  15. 15

    Building a poker probabilities calculator - how can I collect data about objects which keep getting deleted and recreated?

  16. 16

    How can I know which element in a list triggered an any() function?

  17. 17

    How can I know which element in a list triggered an any() function?

  18. 18

    When a user clicks, how can I collect the x/y as well as any link that may have been clicked?

  19. 19

    How can i add a dialog which will show a particular file details?

  20. 20

    How can i show the results which as multiple values in the column in SQL

  21. 21

    Can I show strings on ncurses screen without getch() function?

  22. 22

    Is there any way I can get all of the functions of a module so I can call them?

  23. 23

    why the view pager show the last image of an array each time i select any image of them?

  24. 24

    Restangular / Json-ld | I can get the data, but I can't show them

  25. 25

    How can I show any object as string in JavaScript?

  26. 26

    iTextSharp Table: do I need to DIM any cell or column or can I reuse them?

  27. 27

    Are there any multiformat image viewers, which are similar to feh and can show SVG files?

  28. 28

    How can I get only the specific H3 I am hovering over to show and not all of them?

  29. 29

    How can I create Views in xml which I can use for any layout?

HotTag

Archive