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 8491991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:35:26+00:00 2026-06-10T22:35:26+00:00

nothing happens when I click on item of list view here is code @SuppressLint(ParserError)

  • 0

nothing happens when I click on item of list view here is code

@SuppressLint("ParserError")
public class DinerList extends Activity implements Comparator<CanteenTagEntry>,
        OnItemSelectedListener {
    List<CanteenTagEntry> dinerlist;
    int size;
    int[] arr;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.diner_list);
        ListView listView1 = (ListView) findViewById(R.id.list);
        Context con = getApplicationContext();
        DatabaseHelper dbHelper = new DatabaseHelper(con);
        ICanteenLogRepository repository = dbHelper.getCanteenLogRepository();

        try {
            dinerlist = repository.total();
            Collections.sort(dinerlist, new DinerList());
            Collections.sort(dinerlist, new sortbyuser());
            Collections.sort(dinerlist, new sortbycompany());

            size = dinerlist.size();
            arr = new int[size];
            for (int i = 0; i < size; i++) {
                CanteenTagEntry tagentry = dinerlist.get(i);
                int b = tagentry.getId();
                System.out.print(b);
                arr[i] = tagentry.getId();
                System.out.print(arr[i]);
            }

        } catch (SQLException e) {
            Log.d("DinerList", "Unable to retrieve diner list", e);
        }
        CanteenAdapter adapter = new CanteenAdapter(this,
                R.layout.listview_item_row,
                (ArrayList<CanteenTagEntry>) dinerlist);
        listView1.setAdapter(adapter);
    }

    public class CanteenAdapter extends ArrayAdapter<CanteenTagEntry> {

        Context context;
        int layoutResourceId;
        ArrayList<CanteenTagEntry> data = (ArrayList<CanteenTagEntry>) dinerlist;

        public CanteenAdapter(Context context, int layoutResourceId,
                ArrayList<CanteenTagEntry> data) {
            super(context, layoutResourceId, dinerlist);
            this.layoutResourceId = layoutResourceId;
            this.context = context;
            this.data = (ArrayList<CanteenTagEntry>) dinerlist;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View row = convertView;
            RouteHolder holder = null;
            if (row == null) {
                LayoutInflater inflater = ((Activity) context)
                        .getLayoutInflater();
                row = inflater.inflate(layoutResourceId, parent, false);
                holder = new RouteHolder();
                holder.txtName1 = (TextView) row.findViewById(R.id.Title1);
                holder.txtName2 = (TextView) row.findViewById(R.id.Title2);
                holder.txtName3 = (TextView) row.findViewById(R.id.Title3);

                row.setTag(holder);
            } else {
                holder = (RouteHolder) row.getTag();
            }
            CanteenTagEntry tagentry = data.get(position);
            String idcolor = tagentry.getUser().getIdcolor().toString();

            try {
                holder.txtName1.setTextColor(Color.parseColor(idcolor));
                holder.txtName2.setTextColor(Color.parseColor(idcolor));
                holder.txtName3.setTextColor(Color.parseColor(idcolor));
            } catch (Exception e) {
                holder.txtName1.setTextColor(Color.GRAY);
                holder.txtName2.setTextColor(Color.GRAY);
                holder.txtName3.setTextColor(Color.GRAY);
            }

            holder.txtName1.setText(tagentry.getUser().getUserType().getName());
            holder.txtName2.setText(tagentry.getUser().getCompany().getName());
            holder.txtName3.setText(tagentry.getUser().getFirstName());

            return row;
        }

        class RouteHolder {
            TextView txtName1;
            TextView txtName2;
            TextView txtName3;
            TextView txtName4;

        }

    }

    @Override
    public int compare(CanteenTagEntry o1, CanteenTagEntry o2) {
        return o1.getUser().getFirstName()
                .compareTo(o2.getUser().getFirstName());

    }

    public class sortbyuser implements Comparator<CanteenTagEntry> {

        @Override
        public int compare(CanteenTagEntry lhs, CanteenTagEntry rhs) {
            return lhs.getUser().getUserType().getName()
                    .compareTo(rhs.getUser().getUserType().getName());

        }

    }

    public class sortbycompany implements Comparator<CanteenTagEntry> {

        @Override
        public int compare(CanteenTagEntry lhs, CanteenTagEntry rhs) {
            return lhs.getUser().getCompany().getName()
                    .compareTo(rhs.getUser().getCompany().getName());

        }

    }

    @Override
    public void onItemSelected(AdapterView<?> l, View v, int position,
            long ide) {
        super.onListItemClick(l, v, position, ide);
        CanteenTagEntry tagentry = null;
        int pos = position;
        int id = arr[pos];
        int userid = 0;
        Context con = getApplicationContext();
        DatabaseHelper dbHelper = new DatabaseHelper(con);
        ICanteenLogRepository repository = dbHelper.getCanteenLogRepository();
        try {
            tagentry = repository.Retrieve(id);
            userid = tagentry.getUser().getId();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        try {
            StartFood food = new StartFood(id, userid);

        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    @Override
    public void onNothingSelected(AdapterView<?> arg0) {
        // TODO Auto-generated method stub

    }

}
  • 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-10T22:35:27+00:00Added an answer on June 10, 2026 at 10:35 pm

    i thin you need to used

    listview.setOnItemClickListener(new OnItemClickListener() {
    
            @Override
            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                    long arg3) {
                // TODO Auto-generated method stub
    
    
                   // do your work here 
    
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I click the button and nothing happens. If I take out the validation code,
I did this menu and when I click a menu item nothing happens, it
We have place a button on a view. When we press it, nothing happens.
I have right now this code: <ul><li class=listitem>text<li></ul> jQuery: $('.listitem').click(function() { $(#elname).text($(this).text()); $('#slists').css('visibility','hidden') $('#elname').css('visibility','visible')
On click of delete link (which is a button) nothing happens. I mean form
i have a similar list: <a id=item1 class=outofstock>item 1</a> <a id=item2 class=outofstock>item 2</a> <a
I'm following a tutorial here: http://blog.chariotsolutions.com/2012/01/from-list-to-details-view-using.html I am trying to dynamically bind a click
This function only works once, when I click an anchor element again, nothign happens.
I have seen many question and applied their results but nothing happens I still
For some reason, nothing happens when I run this macro. What might I be

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.