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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:55:13+00:00 2026-05-22T11:55:13+00:00

I have searched the web for a way to do this, but perhaps I’m

  • 0

I have searched the web for a way to do this, but perhaps I’m not searching for the right thing. I have a ListView that serves as a live feed, essentially. In each feedEntry object of this ListView (ArrayList) the application displays words separated by a space as one String. Here’s an example of what one ListView item (one feedEntry) would display:

Sahara Africa Ohio Libya

I would like to have it so that the user can click on each word and a PopupWindow will display (which will, in turn have separate links in it). I understand how to set up this PopupWindow, but how would I attach an onClickListener for each of these words? I’m not sure which code would be helpful to you, but here is my main Feed activity (Feed.java):

public class Feed extends Activity {
ListView liveFeed;
static ArrayAdapter<feedEntry> aa;

static ArrayList<feedEntry> entries = new ArrayList<feedEntry>();

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

    liveFeed = (ListView)this.findViewById(R.id.liveFeed);

    int layoutID = android.R.layout.simple_list_item_1;
    aa = new ArrayAdapter<feedEntry>(this, layoutID, entries);
    liveFeed.setAdapter(aa);


    final Handler handler = new Handler();
    Timer time = new Timer();
    TimerTask refresh = new TimerTask(){
        public void run(){
            handler.post(new Runnable(){
                public void run(){
                    feedEntry.refreshFeed();
                }
            });
        }
    };
    time.scheduleAtFixedRate(refresh, 0, 5000);
  }
}

Here is my feedEntry class (for each feedEntry item in the ListView):

public class feedEntry {
private static int line=1;//use later
private String keywords;
private JSONArray data;

public feedEntry(JSONArray obj){
    data = obj;
    keywords="";
    try{
        for (int i=0;i<data.length();i++){
            JSONArray tmp = (JSONArray)data.get(i);
            keywords += tmp.get(0)+" ";
        }

    } catch(JSONException e){
        e.printStackTrace();
    }
} 

public String toString(){
    return keywords;
}

public static void addNewEntry(feedEntry entry){
    Feed.entries.add(0, entry);
    Feed.aa.notifyDataSetChanged();//notify the array adapter that data has changed
}

//connects to and parses the feed
static public void refreshFeed(){
    try{
        String url = "http://192.17.254.11:8080/getdata?nextline="+line;
        line++;
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpget = new HttpGet(url);
        HttpResponse response;
        response = httpclient.execute(httpget);
        HttpEntity entity = response.getEntity();
        InputStream in = entity.getContent();

        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        StringBuilder sb = new StringBuilder();

        String input = null;
        try {
            while ((input = reader.readLine()) != null) {
            sb.append(input + "\n");
            }
        } catch (IOException e) {
                e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
         }
        String enter = sb.toString();
        if (!enter.equals("None")){
            JSONArray jArray = new JSONArray(enter);
            feedEntry add = new feedEntry(jArray);
            addNewEntry(add);
        }

        in.close();

    } catch(MalformedURLException e){
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JSONException e){
        e.printStackTrace();
    }
}
}

Any help is greatly appreciated. Again, I am very sorry for all of the code. I just wanted to give out as much as possible that may be relevant. At this point, I’m sure that I will need to include these onClickListeners in my Feed.java, since that’s the main activity, but I’m not sure how to put them on separate words within a String.

  • 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-22T11:55:13+00:00Added an answer on May 22, 2026 at 11:55 am

    First, I am skeptical that your UX will be very good. Phones are tiny. Users will have great difficulty accurately tapping on one work versus another with lots of words per row.

    Second, I am skeptical that a ListView is the right answer. A GridView would be simpler, if you want rows and columns of words.

    All that being said, you will have to extend ArrayAdapter, override getView(), create individual TextViews per word, and set up OnClickListeners for each TextView.

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

Sidebar

Related Questions

I've searched for this a little but I have not gotten a particularly straight
i have searched the web relentlessly for this and have not found anything -
I have searched the web for resolution of this error, but everything I have
I have searched around, and it seems that this is a limitation in MS
I want to install rsync on windows xp. I have searched the web, but
I have this problem for a long time now, I have searched the web
I have few very simple question. I searched a web for them, but I
I have searched the web for days now but I can't seem to find
I searched the web but haven't found a real good answer for this question..
I have searched quite a bit on the web and on this site and

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.