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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:05:22+00:00 2026-06-10T11:05:22+00:00

I use the most simpliest way in layout to define listview: <ListView xmlns:android=http://schemas.android.com/apk/res/android android:id=@android:id/list

  • 0

I use the most simpliest way in layout to define listview:

<ListView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:drawSelectorOnTop="true" />

Since I need a checked list I use CheckedTextView in listitem template. The user can check as many items in list as he want. It’s working fine.

I have a ListActivity root view:

public abstract class ActivityList extends ListActivity {
 protected ListView listView;
 public abstract void renderListView( String filter );
 @Override
 public void onCreate( Bundle savedInstanceState ) {
  super.onCreate( savedInstanceState );
  setContentView( R.layout.commonlist );
  listView = getListView();
 }
}

It is abstract, because ActivitiList will be the parent for other view classes, like products, clients, etc. The abstract renderlistview() will be implemented by children with SimpleCursorAdapter, eg.:

public class ActivityProductList extends ActivityList {
 @Override
 public void onCreate( Bundle savedInstanceState ) {
  super.onCreate( savedInstanceState );
  ...
  renderListView( null );
 }
 @Override
 public void renderListView( String filter ) {
  listView.setChoiceMode( ListView.CHOICE_MODE_MULTIPLE );
  ...
  SimpleCursorAdapter sca = new SimpleCursorAdapter( this, R.layout.productlistitemchecked, mCursor, from, to );
  setListAdapter( sca );
 }
}

The ActivityProductList is working fine.
The user does it all he want, then clicks on the FINISH button defined and implemented in parent class, where the listview is, too. His event handler is as follows:

protected void getCheckedItems() {
 try {
   String className = this.getListAdapter().getClass().getName();
   Log.e("NanCal", className);
   Class c = this.getListAdapter().getClass();
   ListAdapter la = this.getListAdapter();
   SimpleCursorAdapter ca = ( SimpleCursorAdapter )la;
   Cursor cursor = ca.getCursor();
   SparseBooleanArray selectedItems = listView.getCheckedItemPositions();
   for( int i = 0; i < selectedItems.size(); i++ ) {
    int selectedPosition = selectedItems.keyAt( i );
    cursor.moveToPosition( selectedPosition );
    long rowId = ca.getItemId( selectedPosition );
    Log.d( "", "row id: " + rowId );
   }
  } catch( Exception exception ) {
   Log.e( "NanCalc", exception.getMessage() + "::" + exception.toString() );
  }
}

The concept is: get the selected item’s ids.

However, in the line what I marked by comment the program crashes with error:
eclipse screenshot part

The this.getListAdapter() gives me a CursorAdapter than the cast will crashes.

Could somebody help me please?

  • 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-10T11:05:23+00:00Added an answer on June 10, 2026 at 11:05 am

    I solved the problem with sword…

    I’ve tried to access the SimpleCursorAdapter from parent class (ActivityList). This way didn’t work. Therefore I§ve changed the base class to abstract and add an abstract method which will return the selected row id’s. The abstract method is implemented in child class (ActivityProductList).

    I know this solution doesn’t give mention to the original problem. But it works…

    Thank you all responses.

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

Sidebar

Related Questions

I found that most tutorials use one big router. For example: https://github.com/thomasdavis/backboneboilerplate/blob/gh-pages/js/router.js Wouldn't it
What's the simplest, most standard, and/or most efficient way to split a List into
I thought that a 32-bit process could use at most 2GB RAM, since half
Do most people use .NET's SqlMembershipProvider, SqlRoleProvider, and SqlProfileProvider when developing a site with
Most designers use 1024x768 as a baseline for website development. That allows them to
When I use VIM or most modeless editors (Eclipse, NetBeans etc.) I frequently do
I am looking for what most people use as their collection type when making
I already know that most implementations use a single thread, but is there anything
I just looked at this posting: What is the best or most interesting use
In Actionscript 3, most events use the capture/target/bubble model, which is pretty popular nowadays:

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.