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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:29:40+00:00 2026-05-22T23:29:40+00:00

I am developing an application in android in which i creating a list view

  • 0

I am developing an application in android in which i creating a list view of few items.
I want to call a class on each list item click.Here is my code

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.example.listview.abc;

public class listview extends Activity implements OnItemClickListener {
    public ListView lv1;
    public String[] names = { "Abc", "Xyz", "Pqr", "Jap", "Jay",
            "bla bla" };

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

        lv1 = (ListView) findViewById(R.id.list);
        lv1.setAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, names));
        lv1.setOnItemClickListener(this);
    }


    @Override
    public void onItemClick(AdapterView<?> a, View v, int position, long id) {
         if(position==0){
             Intent i = new Intent(this, abc.class);
             startActivity(i);
            //Toast.makeText(this, "You pressed the first item in the list",
                //  Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(this, "You pressed all other items in the list",
                    Toast.LENGTH_SHORT).show();

        }
         // else if(position==1){
            // start another activity here...
    }

The problem is that when i click the first item it crashes but the click on other item shows the message but when i click on the item for next activity it crashes
i tried to follow this question of stackoverflow but it didn’t work
{
How to jump from ListView to next Activity
}
here is some part of log cat

06-09 12:29:52.111: DEBUG/AndroidRuntime(903): Shutting down VM
06-09 12:29:52.181: INFO/AndroidRuntime(903): NOTE: attach of thread 'Binder Thread #3' failed
06-09 12:29:52.181: INFO/ActivityManager(60): Start proc com.example.listview for activity com.example.listview/.listview: pid=910 uid=10039 gids={}
06-09 12:29:52.310: DEBUG/dalvikvm(903): Debugger has detached; object registry had 1 entries
06-09 12:29:54.670: INFO/ActivityManager(60): Displayed activity com.example.listview/.listview: 2616 ms (total 199904 ms)
06-09 12:29:55.249: DEBUG/dalvikvm(253): GC_EXPLICIT freed 176 objects / 12384 bytes in 3461ms
06-09 12:29:59.940: DEBUG/dalvikvm(125): GC_EXPLICIT freed 878 objects / 48664 bytes in 188ms
06-09 12:30:05.270: DEBUG/dalvikvm(262): GC_EXPLICIT freed 46 objects / 2240 bytes in 183ms
06-09 12:30:50.140: DEBUG/SntpClient(60): request time failed: java.net.SocketException: Address family not supported by protocol
06-09 12:32:52.731: DEBUG/dalvikvm(120): GC_FOR_MALLOC freed 9850 objects / 473648 bytes in 1222ms
06-09 12:35:50.171: DEBUG/SntpClient(60): request time failed: java.net.SocketException: Address family not supported by protocol
06-09 12:40:50.240: DEBUG/SntpClient(60): request time failed: java.net.SocketException: Address family not supported by protocol
06-09 12:45:50.311: DEBUG/SntpClient(60): request time failed: java.net.SocketException: Address family not supported by protocol

And the menifest File is

**

**

<?xml version="1.0" encoding="utf-8"?>
>     <manifest xmlns:android="http://schemas.android.com/apk/res/android"
>       package="com.example.listview" android:versionCode="1"
>       android:versionName="1.0">
>       <application android:icon="@drawable/icon" android:label="@string/app_name">
>           <activity android:name=".listview" android:label="@s tring/app_name">
>           
>               <intent-filter>
>                   <action android:name="android.intent.action.MAIN" />
>                   <category android:name="android.intent.category.LAUNCHER" />
>               </intent-filter>
>           </activity>
>     
>           <activity android:enabled="true" android:name="abc" />
>       </application>
>       <uses-sdk android:minSdkVersion="3" />
>            <uses-permission android:name="android.permission.INTERNET" />
>     </manifest>

**

**

Please have a look at the code and help me out

Thanks in advance..

  • 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-22T23:29:40+00:00Added an answer on May 22, 2026 at 11:29 pm

    Did you correctly register abc.class as an Activity in your AndroidManifest.xml file? That would cause a crash.

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

Sidebar

Related Questions

I am developing console application in .Net and I want to change a behavior
I'm developing an application targeting .NET Framework 2.0 using C# for which I need
When developing an application that sends out notification email messages, what are the best
I`m developing an application using Spring WebFlow 2, Facelets and JSF. One of my
I'm developing an application for Windows Mobile Devices using Visual Studio .NET 2008 whose
I am developing an application to install a large number of data files from
I am developing an application, and have URLs in the format www.example.com/some_url/some_parameter/some_keyword . I
I'm developing and application that runs as a Windows service. There are other components
I'm developing an application for an internal customer. One of the requirements is that
I am developing an application using MVC Preview 5. I have used typed views.

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.