Listview position to webpage

Put your problem here if it does not fit any of the other categories.

Listview position to webpage

Postby la3bna » Wed Apr 13, 2011 8:43 pm

Hi

I want the position in listview to tell the webbrowser wich page to open..

I have a array in string.xml wich i show in listview, when I press a list item it has a position ( I know how to set po s to open viewX and pos 2 to open viewY) but can I read the position and have that number added to a url?

Example:

in my list : vestfold Krets (pos id 27)

web page: http://www.speiding.no/kart/?krets=27

So here is the thing. I want that pos id is put in after krets in the URL.

If some one helps me I will be really glad :)
la3bna
Experienced Developer
Experienced Developer
 
Posts: 72
Joined: Wed Mar 30, 2011 5:49 am
Location: Stavern, Norway

Top

Re: Listview position to webpage

Postby la3bna » Fri Apr 15, 2011 6:02 am

So no one can help me?

how about something like this?

Code: Select all
@Override
   protected void onListItemClick(ListView l, View v, int position, long id) {
      super.onListItemClick(l, v, position, id);
      // Get the item that was clicked
      Object o = this.getListAdapter().getItem(position);
      String position = o.toString();
                 Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.speiding.no/kart/?krets="+position));
                startActivity(browserIntent);


Does this code snippet look to work??
la3bna
Experienced Developer
Experienced Developer
 
Posts: 72
Joined: Wed Mar 30, 2011 5:49 am
Location: Stavern, Norway

Re: Listview position to webpage

Postby la3bna » Fri Apr 15, 2011 6:40 am

Seems like a modification works

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.              lv.setOnItemClickListener(new OnItemClickListener() {
  2.                     @Override
  3.                     public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
  4.                       Object o = lv.getItemAtPosition(position);
  5.                       Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://www.speiding.no/kart/?krets="+ position1));
  6.                 startActivity(browserIntent);
  7. }
  8.                                
  9. }
  10.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


This gives me the position of the item and adds it to the the end (or where I want it ) of the URL...

Im betting that I can take out this line as well
Code: Select all
Object o = lv.getItemAtPosition(position);



Regards from Norway
I want the position number to be in the string
la3bna
Experienced Developer
Experienced Developer
 
Posts: 72
Joined: Wed Mar 30, 2011 5:49 am
Location: Stavern, Norway

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 15 guests