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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:26:55+00:00 2026-06-14T15:26:55+00:00

I am trying to use a cursorAapter to bindview two strings to a textView.

  • 0

I am trying to use a cursorAapter to bindview two strings to a textView. However I seem to be getting a Resources not found exception. I don’t understand why as they are both 2 string types and I am making an entry at the beginning of the program so there will be something to display.

LogCat

10-21 19:44:51.042: E/AndroidRuntime(14930): Uncaught handler: thread main exiting due to uncaught exception
10-21 19:44:51.062: E/AndroidRuntime(14930): android.content.res.Resources$NotFoundException: String resource ID #0x1
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.content.res.Resources.getText(Resources.java:200)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.TextView.setText(TextView.java:2813)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at com.example.mycoursetimetable.TestCursorAdapter.bindView(TestCursorAdapter.java:28)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.support.v4.widget.CursorAdapter.getView(CursorAdapter.java:256)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.AbsListView.obtainView(AbsListView.java:1274)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.ListView.makeAndAddView(ListView.java:1668)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.ListView.fillDown(ListView.java:637)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.ListView.fillFromTop(ListView.java:694)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.ListView.layoutChildren(ListView.java:1521)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.AbsListView.onLayout(AbsListView.java:1113)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.view.View.layout(View.java:6830)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:998)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.LinearLayout.onLayout(LinearLayout.java:918)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.view.View.layout(View.java:6830)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.view.View.layout(View.java:6830)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1119)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.LinearLayout.layoutVertical(LinearLayout.java:998)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.LinearLayout.onLayout(LinearLayout.java:918)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.view.View.layout(View.java:6830)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.view.View.layout(View.java:6830)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.view.ViewRoot.performTraversals(ViewRoot.java:996)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.view.ViewRoot.handleMessage(ViewRoot.java:1633)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.os.Handler.dispatchMessage(Handler.java:99)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.os.Looper.loop(Looper.java:123)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at android.app.ActivityThread.main(ActivityThread.java:4363)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at java.lang.reflect.Method.invokeNative(Native Method)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at java.lang.reflect.Method.invoke(Method.java:521)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
10-21 19:44:51.062: E/AndroidRuntime(14930):    at dalvik.system.NativeStart.main(Native Method)
10-21 19:44:51.082: I/dalvikvm(14930): threadid=7: reacting to signal 3

Main Activty

public class MyCourses extends Activity {

    static final String TEST = "com.example.mycoursetimetable.TEST";
    database MODULEDATABASE;  
    ListView listContent;
    Cursor cursor;

        @Override
        public void onCreate(Bundle savedInstanceState) 
        {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_my_courses);

       listContent =(ListView)findViewById(R.id.list);
       MODULEDATABASE = new database(MyCourses.this);

       MODULEDATABASE.createEntry("TestCode", "TestName");

       MODULEDATABASE.openToRead(); // don't forget this part!
       cursor = MODULEDATABASE.getData();

       listContent = (ListView)findViewById(R.id.list);
       TestCursorAdapter ca = new TestCursorAdapter(this, cursor, 0);
       listContent.setAdapter(ca);

        }

}

Cursor Adapter

public class TestCursorAdapter extends CursorAdapter {

    private LayoutInflater viewInflater;

    public TestCursorAdapter(Context context, Cursor c, int flags) {
        super(context, c, flags);
        // TODO Auto-generated constructor stub
        viewInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public void bindView(View v, Context context, Cursor c) {
        TextView text_moduleId = (TextView)v.findViewById(R.id.labelDay);
        TextView text_modulecode = (TextView)v.findViewById(R.id.labelModuleCode);
        TextView text_modulename = (TextView)v.findViewById(R.id.labelEditModuleFull);

        //text_moduleId.setText(c.getString(c.getColumnIndex(database.KEY_ROWID)));
        text_modulecode.setText(c.getColumnIndex(database.KEY_MODULECODE));
        text_modulename.setText(c.getColumnIndex(database.KEY_MODULENAME));
    }

    @Override
    public View newView(Context context, Cursor c, ViewGroup parent) {
        View v = viewInflater.inflate(R.layout.listcourses, parent, false);
        return v;
    }

}

database snippet

   public void onCreate(SQLiteDatabase db) {
            db.execSQL("CREATE TABLE " + DATABASE_TABLE +  " (" +
                        KEY_ROWID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
                        KEY_MODULECODE + " TEXT, " +
                        KEY_MODULENAME + " TEXT); "
                    );
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            // TODO Auto-generated method stub
            db.execSQL("DROP TABEL IF EXISTS " + DATABASE_TABLE);
            onCreate(db);
        }
    }

    public database(Context c){
        myContext = c;
    }

    public  database openToWrite()throws SQLException{
        myHelper = new DbHelper(myContext);
        moduleDatabase = myHelper.getWritableDatabase();
        return this;
    }

    public  database openToRead()throws SQLException{
        myHelper = new DbHelper(myContext);
        moduleDatabase = myHelper.getReadableDatabase();
        return this;
    }
    public void close(){
    myHelper.close();
    }

    public long createEntry(String moduleCode, String moduleName) {
        ContentValues cv = new ContentValues();
        cv.put(KEY_MODULECODE,moduleCode);
        cv.put(KEY_MODULENAME,moduleName);
        return moduleDatabase.insert(DATABASE_TABLE,null,cv);
        // TODO Auto-generated method stub

    }

    public Cursor getData() {

        String[] columns = new String [] {KEY_ROWID,KEY_MODULECODE, KEY_MODULENAME};
        Cursor c = moduleDatabase.query(DATABASE_TABLE, columns, null, null, null, null, null);

        return c;
    }


}
  • 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-14T15:26:57+00:00Added an answer on June 14, 2026 at 3:26 pm

    I guerss this line is the problem:

     text_modulecode.setText(c.getColumnIndex(database.KEY_MODULECODE));
    

    the columnIndex is most likely an int, which is interpreted as a resourceId. Thats why it is searching for resource ID 1 (the column index). Use

    ....setText(String.valueOf(c.getColumnIndex(database.KEY_MODULECODE)));
    

    to make sure you use the method that takes a String.

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

Sidebar

Related Questions

trying to use hibernate with my web app and getting following exception: Initial SessionFactory
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I am trying use javascript regular expressions to do some matching and I found
I want use localized strings from resources in xsl template as in aspx page,
I am trying use an if statement and TWO .addClass background-color variables based on
I am trying use std::copy to copy from two different iterator. But during course
I have a regex that I'm trying use to validate against strings. Trying to
I am trying use Accrev plugin for visual studio 2010. I am not sure
I'm trying to create a custom cursoradapter that will use two different layouts depending
I'm trying use jquery to remove a class from an element (not knowing ahead

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.