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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:33:52+00:00 2026-06-01T03:33:52+00:00

i have implemented a list view its working fine but when i click on

  • 0

i have implemented a list view its working fine but when i click on the list it gives me raw data that getItemAtPosition(position) returns me.

following is the code that i am using

public class FirstTab extends Activity{

    private TabHostProvider tabProvider;
    private TabView tabView;
    private static String[] country1;
    private ListView speakerList;
    final Handler mHandler = new Handler();


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Context context = getApplicationContext();
        tabProvider = new TabbarView(this);
        tabView = tabProvider.getTabHost("main");
        tabView.setCurrentView(R.layout.firsttab);
        setContentView(tabView.render(0));
        String temp[] = new String[]{"furqan","furqan1","furqan2"};
        Weather weather_data[] = new Weather[temp.length];
        for(int i = 0;i<temp.length;i++)
        {
            weather_data[i] = new Weather(R.drawable.ic_launcher, temp[i]);
        }

        WeatherAdapter adapter = new WeatherAdapter(this,R.layout.listview_item_row, weather_data);
        speakerList = (ListView)findViewById(R.id.speakerList);
        View header = (View)getLayoutInflater().inflate(R.layout.listview_header_row, null);
        speakerList.addHeaderView(header);
        speakerList.setAdapter(adapter);

        final ViewFlipper viewflipper = (ViewFlipper) findViewById(R.id.viewflipper);
        speakerList.setOnItemClickListener(new OnItemClickListener() {

            public void onItemClick(final AdapterView<?> arg0, View arg1, final int arg2,long arg3) {
                // TODO Auto-generated method stub


                String item = speakerList.getItemAtPosition(arg2).toString();
                Log.d("the  value is", item);
                        /*View item = (View) (speakerList.getItemAtPosition(arg2));
                        String item = arg0.getItemAtPosition(arg2).toString();
                        Log.d("the  value is", item);*/
                        //Toast.makeText(getApplicationContext(), arg2, 1).show();



            }

        });

    }   
}

The above is the main activity.Following is the adapter

public class weatheradapter {



    public static class WeatherAdapter extends ArrayAdapter<Weather>{

        Context context; 
        int layoutResourceId;    
        Weather data[] = null;

        public WeatherAdapter(Context context, int layoutResourceId, Weather[] data) {
            super(context, layoutResourceId, data);
            this.layoutResourceId = layoutResourceId;
            this.context = context;
            this.data = data;
        }

        static class WeatherHolder
        {
            ImageView imgIcon;
            TextView txtTitle;
        }



        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View row = convertView;
            WeatherHolder holder = null;

            if(row == null)
            {
                LayoutInflater inflater = ((Activity)context).getLayoutInflater();
                row = inflater.inflate(layoutResourceId, parent, false);

                holder = new WeatherHolder();
                holder.imgIcon = (ImageView)row.findViewById(R.id.imgIcon);
                holder.txtTitle = (TextView)row.findViewById(R.id.txtTitle);

                row.setTag(holder);
            }
            else
            {
                holder = (WeatherHolder)row.getTag();
            }

            Weather weather = data[position];
            holder.txtTitle.setText(weather.title);
            holder.imgIcon.setImageResource(weather.icon);

            return row;
        }


    }
}

this is the xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center" android:gravity="center" android:background="#00FFcc">

    <ViewFlipper android:id="@+id/viewflipper" android:layout_width="fill_parent" android:layout_height="fill_parent" > 

        <ListView android:id="@+id/speakerList" android:layout_width="fill_parent" android:layout_height="fill_parent" />

        <ListView android:id="@+id/categoryList" android:layout_width="fill_parent" android:layout_height="wrap_content" />


    </ViewFlipper>

</LinearLayout>

The following is the layout for the list view

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" 
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dp">

     <ImageView android:id="@+id/imgIcon"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:gravity="center_vertical"
        android:layout_alignParentTop="true"
        android:layout_alignParentBottom="true"
        android:layout_marginRight="15dp"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="5dp" />



       <TextView android:id="@+id/txtTitle"
         android:text="@+id/txtTitle"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center_vertical"
        android:layout_alignParentTop="true"
        android:layout_alignParentBottom="true"
        android:textStyle="bold"
        android:textSize="22dp"
        android:textColor="#000000"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="5dp" />

</LinearLayout>

need help thanks

  • 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-01T03:33:54+00:00Added an answer on June 1, 2026 at 3:33 am
    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
        Cursor c = (Cursor) parent.getAdapter().getItem(position);
        c.getString(c.getColumnIndex("col_name")));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have implemented a custom list view which looks like the twitter timeline. adapter
I have an ExpandableListView view and I've implemented OnChildClickListener , but I need to
I have a JQuery Mobile (1.0rc1) application that has a list view with a
I'd like to implement a ListView that will have a list of SelectedItems as
I have to implement a one linked list but it should put object in
I have a website that lets people view rows in a table (each row
I have implemented a large list of views in a UIScrollView. I cannot use
I have a list of items that have a partial order relation , i.
I have made list view with checkboxes. I have read similar articles n many
i have made menu list containing play, settings, exit. but clicking the button doesn

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.