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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:35:57+00:00 2026-06-03T15:35:57+00:00

I have a SQLite db and I want to see in a ListView all

  • 0

I have a SQLite db and I want to see in a ListView all the elements. But I want to make every row clickable. How to do this? Here is the code:
Then.. another question.. I have an activity that I can launched by the options menu and it add or remove data from the db.. I want to autoupdate the list when i come back to this activity.. How can I change the code?.

public class WorkflowChoice extends Activity {

private static final int INIT_JADE_PROFILE = 0;
private static final int MANAGE_DATABASE = 1;
private static final int MODIFY_FILES = 2;
private static final int CHANGE_THEME = 3;
private static final int SHOW_OUTPUT_WORKFLOW = 4;
private LinearLayout properties_container;

private MyDatabase db;
TextView wfsTv;
ListView wfsLv;
private Cursor c;

public MyDatabase getDb() {
    return db;
}
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.choice);

    properties_container = (LinearLayout ) findViewById(R.id.properties_container);

    String host = (String) InitJadeProperties.retrieve(this, getString(R.string.main_container_host), getString(R.string.default_host));
    String port = (String) InitJadeProperties.retrieve(this, getString(R.string.main_container_port), getString(R.string.default_port));

    wfsTv=(TextView)findViewById(R.id.wfsTv);
    ListView wfsLv = (ListView)findViewById(R.id.wfsLv);

    db=new MyDatabase(getApplicationContext());
db.open();  //apriamo il db


if(db.fetchWfs().getCount()==0){//inserimento dati, solo se il db è vuoto

        db.insertWf("WF1", "class1");
        db.insertWf("WF2", "class2");
        db.insertWf("WF3", "class3");
        db.insertWf("WF4", "class4");
        db.insertWf("WF5", "class5"); 

}

c=db.fetchWfs(); // query
startManagingCursor(c);

SimpleCursorAdapter adapter=new SimpleCursorAdapter( //semplice adapter per i cursor
                this, 
                R.layout.wfs, //il layout di ogni riga/prodotto 
                c, 
                new String[]{MyDatabase.WfMetaData.ID,MyDatabase.WfMetaData.WF_NAME_KEY,MyDatabase.WfMetaData.WF_CLASS_KEY},//questi colonne 
                new int[]{R.id.IDTv,R.id.nameTv,R.id.classTv});//in queste views

wfsLv.setAdapter(adapter); //la listview ha questo adapter


//qui vediamo invece come reperire i dati e usarli, in questo caso li stampiamo in una textview

int nameCol=c.getColumnIndex(MyDatabase.WfMetaData.WF_NAME_KEY);  //indici delle colonne
int classCol=c.getColumnIndex(MyDatabase.WfMetaData.WF_CLASS_KEY);       

if(c.moveToFirst()){  //se va alla prima entry, il cursore non è vuoto
        do {

                wfsTv.append("Wf Name:"+c.getString(nameCol)+", Class:"+c.getString(classCol)+"\n"); //estrazione dei dati dalla entry del cursor

                } while (c.moveToNext());//iteriamo al prossimo elemento
}

db.close();
getWindow().setFormat(PixelFormat.RGBA_8888);   //visto che usiamo i gradient, usiamo questo trick (vedi snippet forum)
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);  

//wfsLv.setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[]{Color.RED,Color.parseColor("#f2bf26")}));
//wfsTv.setBackgroundDrawable(new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, new int[]{Color.RED,Color.parseColor("#f2bf26")}));
//definizione ed uso di gradient in modo programmatico


//animazioni in modo programmatico (vedi snippet forum)
Animation a1 = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_PARENT, 1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
a1.setDuration(1000);
a1.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.decelerate_interpolator));
wfsLv.startAnimation(a1);
//entra da sotto


Animation a2 = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_PARENT, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
a2.setDuration(1000);
a2.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.anim.decelerate_interpolator));
wfsTv.startAnimation(a2);
//entra da sopra


wfsLv.setClickable(true);
//e affidiamo la gestione del tap/click ad un apposito listener, che ci permetterà di agire sull’elemento cliccato e ricaricare la nostra lista

wfsLv.setOnItemClickListener
       (new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent,
          View v, int position, long id) {
 TextView txtId = (TextView)
          v.findViewById(R.id.wfsTv); 
 c.requery(); 
}
       });

/*wfsTv.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            CharSequence text = "Workflow scelto!";
            int duration = Toast.LENGTH_SHORT;

            Toast toast = Toast.makeText(getApplicationContext(), text, duration);
            toast.show();

        }
    });*/



    TextView masterTv = (TextView)findViewById(R.id.masterTv);
    masterTv.setText("Master");
    masterTv.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startSubActivity();

        }
    });
}
private void startSubActivity(){
Intent intent = new Intent(this, ConfigChoice.class);
startActivity(intent);
}
  • 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-03T15:35:59+00:00Added an answer on June 3, 2026 at 3:35 pm

    for your 1 st question i have

      list.setOnItemClickListener(new OnItemClickListener() {
    
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position,long id) {
    
    // here you will get **position** of the item in the list which you can use gor updation/deletion
    
                    }
    
    
                });
    

    and for the second question

    write your 2nd question-

    write your listview intialization code in onResume() method so it will be getting called every time when you came back to this activity..

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

Sidebar

Related Questions

I have a SQLite db and I want to see in a ListView all
In my SQLite database only one row effect but I want effect 4 rows
I want to insert some data to mydatabase.sqlite but I have a problem. There
I have a DataTable which I want to save to a SQLite Database Table.
I have a component that i want to store to an SQLite database. public
I have a sqlite DB created by my CoreData model automatically, but my app
I have a *.sqlite file... but I need the database in *.sl3 format? What
Let's say I have a list of IDs and I want to see if
I have an SQLite table blog_posts . Every blog post has an id and
I have this line that works OK: c.execute('select cleanseq from cleanseqs WHERE newID=%s'%name) But

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.