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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:44:39+00:00 2026-05-23T14:44:39+00:00

Here is my code – everything. I did as you told but I still

  • 0

Here is my code – everything. I did as you told but I still can`t click on nothing. I mean I can click but nothing happens


package fixus.core;

import java.util.ArrayList;
import java.util.Iterator;

import android.app.ListActivity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import fixus.lib.News;
import fixus.testing.DataInput;

public class NewserActivity extends ListActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        DataInput di = new DataInput();
        ArrayList news = di.getNews();

        NewsArrayAdapter naa = new NewsArrayAdapter(NewserActivity.this, R.layout.row, news);
        setListAdapter(naa);
        ListView lv = getListView();

        lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView parent, View view,
          int position, long id) {
        Log.i("testy", "I Clicked on Row " + position + " and it worked!");
      }
    });


   }

    @Override
    /**
     * When the user selects an item in the list, do an action
     * @param ListView l
     * @param View v
     * @param int position
     * @param long id
     */
    protected void onListItemClick(ListView l, View v, int position, long id) {
        super.onListItemClick(l, v, position, id);

        final int index = position;

        //You can add whatever you want to happen when you click here

        Log.i("testy", "I Clicked on Row " + index + " and it worked!");

    }


    private class NewsArrayAdapter extends ArrayAdapter {
        protected ArrayList items;

        public NewsArrayAdapter(Context context, int textViewResourceId, ArrayList items) {
            super(context, textViewResourceId, items);
            this.items = items;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View v = convertView;

            if(v == null) {
                LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v = vi.inflate(R.layout.row, null);
            }

            News news = this.items.get(position);
            if(news != null) {
                TextView tt = (TextView) v.findViewById(R.id.toptext);
                TextView bt = (TextView) v.findViewById(R.id.bottomtext);

                if (tt != null) {
                      tt.setText("Name: "+ news.getName());
                }
                if(bt != null){
                      bt.setText("Status: "+ news.getUrl().toString());
                }
            }

            return v;
        }
    }

}

If you know a good tutorial/example that would show me the good way I would love to see it 🙂

  • 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-23T14:44:39+00:00Added an answer on May 23, 2026 at 2:44 pm

    In your list activity what you should do is something like the following:

    public class YourClass extends ListActivity {
        //Your Variables
        ArrayList<Type> yourlist;
        YourAdapterClass adapter;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            yourlist = new ArrayList<Type>();
            this.adapter = new YourAdapterClass(this, R.layout.row, yourlist);
            setListAdapter(this.adapter);
            //you might be able to see if the below works instead of overriding 
            ListView lv = getListView();
    
            lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,
              int position, long id) {
            Log.i("testy", "I Clicked on Row " + position + " and it worked!");
          }
        });
        }
    
        @Override
        /**
         * When the user selects an item in the list, do an action
         * @param ListView l
         * @param View v
         * @param int position
         * @param long id
         */
        protected void onListItemClick(ListView l, View v, int position, long id) {
            super.onListItemClick(l, v, position, id);
    
            final int index = position;
    
            //You can add whatever you want to happen when you click here
    
            Log.i("testy", "I Clicked on Row " + index + " and it worked!");
    
        }
    
    //other methods can go here for you list
    
    
    }
    

    You don’t want to have your onClickListener inside your getView(...) method in the List Adapter, that is just where you are suppose modify the way your row looks like (adding buttons, textfields, etc. for each row) instead you want to have the onClickListener in a class that extends ListActivity that connects to your Adapter

    Good luck, hope this helped

    //Edit (adding more info)

    You need to ‘add it to your adapter’ in the onCreate method (see edited code above) Hopefully that should fix the problem. Let me know if it still doesn’t work though. If that doesn’t work you can try using the setOnItemClickListener code I put in the onCreate method instead, if that still doesn’t work I would try checking out some tutorials (I’ll see if i can find you a good one)

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

Sidebar

Related Questions

Edit: The code here still has some bugs in it, and it could do
here is code: $(#addpesel).click(function(){ var properties = { height: 280, reloadAfterSubmit: true, closeAfterAdd: true,
here is code i used to query fan speed, but fan speed always return
The code here can generate numbers like this [1 -2 3 -4 5 -6
Here code of my project. I use direct Tcp connection But i get Could
Ok the error is showing up somewhere in this here code if($error==false) { $query
Here is code from MSDN . I don't understand why the work isn't just
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),
enter code here I have a table on SQL server 2005 with bigint primary
The code here is X++. I know very little about it, though I am

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.