---
title: "Hot to show info based on what user profile has in android?"  
description: "Hot to show info based on what user profile has in android?"  
author: "Anonymous User"  
published: 2014-11-18  
updated: 2014-11-19  
canonical: https://www.mindstick.com/forum/12632/hot-to-show-info-based-on-what-user-profile-has-in-android  
category: "android"  
tags: ["listview"]  
reading_time: 2 minutes  

---

# Hot to show info based on what user profile has in android?

I have a [ListView](https://www.mindstick.com/articles/12744/listview-in-android) and each [row](https://www.mindstick.com/forum/1212/this-row-already-belongs-to-this-table) contains a different [User](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) object.

A User has these different [fields](https://www.mindstick.com/forum/159126/sql-query-for-all-tables-and-fields-in-an-oracle-db):

- List of things I like
- List of things I hate
- List of [games](https://www.mindstick.com/articles/13085/the-most-famous-casino-games) I play
- Description of myself

[Now](https://yourviews.mindstick.com/view/81402/it-s-liberals-vs-progressives-in-us-politics-now), when I [populate](https://www.mindstick.com/blog/60/populate-records-in-second-listbox-according-to-the-selection-in-first-list-box) the ListView, I want to show different things that each user has filled out. So for example, one row might show 'things I like' filled out, while another might show the 'description of myself'.

I don't want to adjacent rows to be showing the same type of row. All this [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) will be inserted into my BaseAdapter's getView methood.

What would be the best [logic](https://www.mindstick.com/articles/331924/best-ways-to-improve-your-logic-building-skills-for-programming) in [terms](https://answers.mindstick.com/qa/31698/what-is-the-real-value-of-us-dollars-in-terms-of-indian-rupee) of pseudocode to achieve this?

```
// Creates arraylist of elements that are complete in profileList<String> profileElements = new ArrayList<String>();if (user.getGameOwned() != null && user.getGameOwned().size() > 2) {    profileElements.add(KEY_GAMES_PLAYED);}if (user.getAboutMe() != null && !user.getAboutMe().isEmpty()) {    profileElements.add(KEY_ABOUT_ME);}if (user.getIAm() != null && user.getIAm().length > 2) {    profileElements.add(KEY_I_AM);}if (profileElements.size() > 0) {    String randomElement = profileElements.get(new Random().nextInt(profileElements.size() - 1));    if (randomElement.equals(KEY_GAMES_PLAYED)) {        // do whatever here    }    else if (randomElement.equals(KEY_ABOUT_ME)) {        // do whatever    }}
```

## Replies

### Reply by Anonymous User

You could try this approach, in your BaseAdapter put a verification if what list do you want to show.

## For example:

```
int ctr = 1; // your counter - try to declare it on the
global level if(ctr<4){//your 4 types of list -      display(ctr); //print
the current ctr     ctr++;}else{     display(ctr);     ctr = 1; //make
the value to 1 for the next batch of loop}
```

**code:**

```
display(int index){     switch (index){        case 1:             //List of things I like            break;        case 2:             //List of things I hate            break;        case 3:            //List of games I play            break;        case 4:             //Description of myself            break;        default:            break;    }}
```

You could also do random.nextInt(4) but it might have the same result each row.


---

Original Source: https://www.mindstick.com/forum/12632/hot-to-show-info-based-on-what-user-profile-has-in-android

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
