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

  • Home
  • SEARCH
  • 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 7723947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:34:18+00:00 2026-06-01T04:34:18+00:00

I have following Code package cyclist.project; import java.util.ArrayList; import java.util.List; import org.json.JSONArray; import org.json.JSONException;

  • 0

I have following Code

package cyclist.project;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;

import cyclist.Utility.AppLog;
import cyclist.Utility.common;
import cyclist.Utility.webService;
import cyclist.bean.discussion_item;
import cyclist.dal.Attributes;
import cyclist.dal.DBHelper;
import cyclist.dal.DBService;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class user_discussion  extends Activity{

    ListView events;
    ArrayList<discussion_item> list;
    static EditText et;
    Button btn; 

    webService webService;
    cyclist.Utility.common common;
    DBService dbService;
    DBHelper dbHelper;
    Attributes attributes;

    public void onCreate(Bundle savedInstanceState) {

        webService = new cyclist.Utility.webService(this);
        common = new common();
        dbHelper = new DBHelper(this);
        dbService = new DBService(dbHelper);

        super.onCreate(savedInstanceState);
        setContentView(R.layout.user_discussion);
        events = (ListView) findViewById(R.id.lv_user_discussion_list);
        et = (EditText) findViewById(R.id.lv_list_events_listT);
        btn = (Button) findViewById(R.id.lv_list_events_list);
        list = new ArrayList<discussion_item>();

        showTime();
        setList();

        events.setAdapter( new ListAdapter(user_discussion.this, list) );
        // new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list)
    }

    public void register(View view) {
        Intent intent = new Intent("com.google.android.c2dm.intent.REGISTER");
        intent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
        intent.putExtra("sender", "myemail@gmail.com");
        startService(intent);
        et.setText("");
    }

    public void showTime() {
//      ListAdapter la = new ListAdapter(user_discussion.this, list);
//      la.notifyDataSetChanged();
//      SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
//      String string = prefs.getString(AUTH, "n/a");
//      Toast.makeText(this, string, Toast.LENGTH_LONG).show();
//      Log.d("C2DM RegId", string);

    btn.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {
            String url = common.setChatInUrl(et.getText().toString() );
            AppLog.logString("url= "+ url);
            String response = webService.getWebResponse(url);               
            setList();
            et.setText("");
            // register(btn);
            }
        });
    }

    private void setList(){
        JSONObject json;
        try {
            json = new JSONObject(JSON.getJSONfromURL("http://myservices/ws_cyc/events_service.php?action=get_chats"));
            JSONArray miles = json.getJSONArray("cyc");
            JSONObject rec;
            JSONObject rec2 = null; 
            discussion_item item = null;

                for (int i=0; i<miles.length(); i++){
                    rec = miles.getJSONObject(i);
                    rec2 = rec.getJSONObject("cycObject");
                    item = new discussion_item(rec2.getString("Chats").toString());
                    list.add(item);
                }                                   
            } catch (JSONException e) {
                e.printStackTrace();
            }   
    }

    @SuppressWarnings("unused")
    private class ListAdapter extends ArrayAdapter<discussion_item> {

        private LayoutInflater inflater;

        public ListAdapter( Context context, List<discussion_item> list ) {
          super( context, R.layout.user_discussion_left_item, R.id.txt_event_item_title, list );
          inflater = LayoutInflater.from(context);       // Cache the LayoutInflate to avoid asking for a new one each time.
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            ViewHolder holder;
//          TextView textView;          
            discussion_item event = (discussion_item) this.getItem(position); 
            AppLog.logString(String.valueOf(position));
            holder = new ViewHolder();

            if ( convertView == null ) {
                if(position%2 == 0){
                    convertView = inflater.inflate(R.layout.user_discussion_left_item, null);
                    holder.textView = (TextView) convertView.findViewById( R.id.txt_event_item_title); 
                    holder.textView.setText(event.getTitle());
                }
                else{
                    convertView = inflater.inflate(R.layout.user_discussion_right_item, null);
                    holder.textView = (TextView) convertView.findViewById( R.id.txt_event_item_title); 
                    holder.textView.setText(event.getTitle());
                }                   
            }
            return convertView;         
        }
      }

     public void NavigateToResult(Context context, Class<?> targetClass) {
            Intent intent = new Intent(context, targetClass);
            startActivity(intent);
            finish();
        }
        @Override 
        public boolean onKeyDown(int keyCode, KeyEvent event)  
        { 

             if (keyCode == KeyEvent.KEYCODE_BACK) 
             {
                 NavigateToResult(this, login.class);
                    return false;           
             }  
          else
              return super.onKeyDown(keyCode, event); 


        }
        static class ViewHolder
        {
            public TextView textView;
            //ImageView imgIcon;
        }
}

I am using PHP JSON Web Service to retrieve the list of Chat. The problem is that my custom list is not displaying properly i.e. it is only show 4 row of chat

0 – hello
1 – hi
2 – how ru?
3 – fine.

the rest is not displayed i.e.

4 – what r ur today’s plan
5 – nothing
6…… so on…

instead of displaying 4-onwards, it is repeating those 0-3 index chats.
Please any help. where am I making mistake?
When I debug my web-service by running it in web-browser, it is returning complete list of chat.

  • 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-06-01T04:34:19+00:00Added an answer on June 1, 2026 at 4:34 am

    @ Ollie C
    Thanx for pointing out the fact..however another user @ code.google.com helped me resolve my query.. The only thing that i asked was whether i am making mistake or not..yes it is vague, but that Genius told me that i should recheck my ListAdapter class

    It turns out that i was making mistake in getView() method.

    Thanks again for advice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following simple Java code: package testj; import java.util.*; public class Query<T>
I have the following code: package application; import java.util.Timer; import java.util.TimerTask; public class Application
I have written following code to get location name package demo.gps.locname; import java.io.IOException; import
I have the following code: package example; import java.awt.BorderLayout; import java.awt.FlowLayout; import javax.swing.JFrame; import
So i have the following code: package animation; import java.awt.Graphics; import java.awt.Image; import java.awt.image.BufferedImage;
I have following file upload code: package net.viralpatel.contact.controller; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller;
I have the following code: package in.res.num.tapb.ui; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Dimension; import
I have the following code package myPackage; import org.neo4j.graphdb; import org.neo4j.kernel.EmbeddedGraphDatabase; public class dbServlet
I have the following scala code: package dummy import javax.servlet.http.{HttpServlet, HttpServletRequest => HSReq, HttpServletResponse
I have the following simple code: package test; import javax.swing.*; class KeyEventDemo { static

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.