Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7663185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:59:40+00:00 2026-05-31T13:59:40+00:00

I am trying to show some data in a ListView. I created my own

  • 0

I am trying to show some data in a ListView.
I created my own Adapter but it doesn’t seem to be working.

I put a break point inside the method “getView(..)” but it never reached it.

I am probably missing something simple but can’t figure it out.

package mpg.scoreControl;

import java.util.ArrayList;

import mpg.playerControl.MPGPlayer;
import mpg.playerControl.MPGPlayerControl;
import multiplayerGameControl.pkg.R;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.SlidingDrawer;
import android.widget.ListView;
import android.widget.TextView;

public class MPGGameScore {

    ArrayList<MPGGameScoreEntry> scores;
    protected class MPGGameScoreEntry{
        public String playerName;
        public int playerScore;
        public MPGGameScoreEntry(String playerName, int playerScore) {
            this.playerName = playerName;
            this.playerScore = playerScore;
        }
    }

    private class GameScoreAdaptor  extends BaseAdapter{


     private LayoutInflater mInflater;
     public GameScoreAdaptor(Context context) {
//        searchArrayList = results;
          mInflater = LayoutInflater.from(context);
         }
    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return 0;
    }


    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return null;
    }


    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return 0;
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
          ViewHolder holder;
          if (convertView == null) {
           convertView = mInflater.inflate(R.layout.playerscoresrow, null);
           holder = new ViewHolder();
           holder.tvwPlayerName = (TextView) convertView.findViewById(R.id.tvwPlayerName);
           holder.tvwPlayerScore = (TextView) convertView.findViewById(R.id.tvwPlayerScore);

           convertView.setTag(holder);
          } else {
           holder = (ViewHolder) convertView.getTag();
          }

          holder.tvwPlayerName.setText(scores.get(position).playerName);
          holder.tvwPlayerScore.setText(scores.get(position).playerScore);

          return convertView;
         }
    }

    static class ViewHolder {
          TextView tvwPlayerName;
          TextView tvwPlayerScore;
    }

    public void showCurrentScores(final  Activity context, SlidingDrawer sd){
        ListView lvwScores = (ListView) sd.findViewById(R.id.lvwScores);


        // Build arraylist with scores.


        scores = new ArrayList<MPGGameScoreEntry>();

        // Now fill it up with rows

        for (MPGPlayer player: MPGPlayerControl.getInstance().players)
            scores.add(new MPGGameScoreEntry(player.playerName,player.playerDetails.playerScore.getScoreInt()));

        lvwScores.setAdapter(new GameScoreAdaptor(context));

    }
}

score_drawer:

<?xml version="1.0" encoding="utf-8"?>

<SlidingDrawer android:id="@+id/slidingDrawer" android:handle="@+id/drawerHandle"
                xmlns:android="http://schemas.android.com/apk/res/android"
                android:content="@+id/contentLayout" android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:layout_alignParentBottom="true" 
                android:visibility="visible">
     <ImageView android:id="@+id/drawerHandle"
                android:src="@drawable/blue_arrow_up_flat"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content">
    </ImageView>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:id="@+id/contentLayout" android:gravity="center"
                  android:layout_width="fill_parent" android:layout_height="wrap_content">

      <ListView
       android:id="@+id/lvwScores" 
       android:layout_width="fill_parent" android:layout_height="wrap_content"  
       android:divider="#FFFFFF" android:dividerHeight="1dip" 
       android:layout_weight="1"  android:layout_marginBottom="60dip"
       android:footerDividersEnabled="true" android:headerDividersEnabled ="true"/>
    </LinearLayout>
</SlidingDrawer>

playerscorerow:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal">

  <TextView android:id="@+id/tvwPlayerName" android:layout_weight="1" android:gravity="left"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"/>
  <TextView android:id="@+id/tvwPlayerScore" android:layout_weight="1" android:gravity="right"
    android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginRight="12sp"
    android:layout_alignParentRight="true"/>
</RelativeLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:59:41+00:00Added an answer on May 31, 2026 at 1:59 pm

    You can’t return 0 in the getCount() method because this will tell your adapter that you don’t have any elements in the adapter:

          @Override
            public int getCount() {
               return  24 ; // I just put a number here,if you plan to use the scores      ArrayList as the data 
    // of the adapter you should return here scores.size();     
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to show a spinning progress while I load some data, but
I'm trying to use dialog to show some data, but unfortunatly the data might
I've got problem. I'm using windows.forms ListView to show some data and I need
I'm trying to have a jQuery autocomplete. I have specified some data but when
I'm trying to show some user info in a listview in jquery mobile. I'm
We are trying to show a table data on a listview. The data consists
I am trying to use Google graph API (image) to show some data in
Im trying to pass to another xib some data of NSMutableArray. I created a
I've been working on a site that requires a graph to show some data,
I'm trying to pass some data from one activity to a new one but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.