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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:53:35+00:00 2026-06-01T19:53:35+00:00

I’ve created this code that populate SQLite in Listview, but what I’m struggeling in

  • 0

I’ve created this code that populate SQLite in Listview, but what I’m struggeling in is that I want to show TOAST message depending on what user chooses from the listview.Should I go with onClick method?.

    public void createTable(SQLiteDatabase mDb, String table) {
        try {
            mDb.execSQL("create table if not exists "
                    + table
                    + " (id integer primary key autoincrement, "
                    + "username text not null, birthday text not null,image text);");
        } catch (SQLException e) {
            Toast.makeText(getApplicationContext(), "yes",
                    Toast.LENGTH_LONG).show();
        }
    }

    public void insert(SQLiteDatabase mDb, String table) {

                    ContentValues values = new ContentValues();


    public void getAllData(String table) {
        Cursor c = mDb.rawQuery("select * from " + table, null);
        int columnsSize = c.getColumnCount();
        listData = new ArrayList<HashMap<String, Object>>();
        while (c.moveToNext()) {
            HashMap<String, Object> map = new HashMap<String, Object>();
            for (int i = 0; i < columnsSize; i++) {
                map.put("id", c.getString(0));
                map.put("username", c.getString(1));
                map.put("birthday", c.getString(2));
                map.put("image", c.getString(3));
            }
            listData.add(map);
        }           
    }
    public boolean delete(SQLiteDatabase mDb, String table, int id) {
        String whereClause = "id=?";
        String[] whereArgs = new String[] { String.valueOf(id) };
        try {
            mDb.delete(table, whereClause, whereArgs);
        } catch (SQLException e) {
            Toast.makeText(getApplicationContext(), "هˆ é™¤و•°وچ®ه؛“ه¤±è´¥",
                    Toast.LENGTH_LONG).show();
            return false;
        }
        return true;
    }
}

OnCreateContextMenuListener listviewLongPress = new OnCreateContextMenuListener(){
    public void onCreateContextMenu(ContextMenu menu, View v,
            ContextMenuInfo menuInfo) {
        final AdapterView.AdapterContextMenuInfo info =
        (AdapterView.AdapterContextMenuInfo) menuInfo;
        new AlertDialog.Builder(ListView_SqliteActivity.this)
                .setTitle("عنوان1")
                .setIcon(android.R.drawable.ic_dialog_info)
                .setMessage("عنوان 2")
                .setPositiveButton("وک¯",
                        new DialogInterface.OnClickListener() {
                            public void onClick(
                                    DialogInterface dialoginterface, int i) {
                                int mListPos = info.position;
                                HashMap<String, Object> map = listData
                                        .get(mListPos);
                                int id = Integer.valueOf((map.get("id")
                                        .toString()));
                                if (dao.delete(mDb, "student", id)) {                                       
                                    listData.remove(mListPos);
                                    listItemAdapter.notifyDataSetChanged();
                                }
                            }
                        })
                .setNegativeButton("هگ¦",
                        new DialogInterface.OnClickListener() {
                            public void onClick(
                                    DialogInterface dialoginterface, int i) {

                            }
                        }).show();
    }
};

@Override
public void finish() {
    // TODO Auto-generated method stub
    super.finish();
    mDb.close();
}

}

  • 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-01T19:53:36+00:00Added an answer on June 1, 2026 at 7:53 pm

    I assume little from your question that you want to implement Click event for the ListView, and you want to display Toast Message for the click.

    So, implement setOnItemClickListener for your listview to handle list item click.

     list.setOnItemClickListener(new ListView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> a, View v, int i, long l) {
               // do whatever you want
            }
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I want to construct a data frame in an Rcpp function, but when I
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text

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.