Shekhar
Shekhar

Reputation: 1767

How to strike out on text of listview once item get selected

I have CheckedTextView with couple of items. I want to get text strike out once I select list and it has to strike out when I reload my app my xml contains following code

<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/title"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:gravity="center_vertical"
    android:checkMark="?android:attr/textCheckMark"
    android:paddingLeft="6dip"
    android:paddingRight="6dip" 
    style="@style/CodeFont"  
/>

and my activity contains following code:

import android.app.ListActivity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.CheckedTextView;
import android.widget.ListView;
import android.widget.Toast;

public class def extends ListActivity {

    /** Called when the activity is first created. */
    static String[] value;
    MediaPlayer mediaPlayer = new MediaPlayer();    
    static int i=0;

    public void onCreate(Bundle icicle) {
    super.onCreate(icicle);     
    Bundle b = getIntent().getExtras();
    value = b.getStringArray("a1");
    this.setListAdapter(new ArrayAdapter<String>(this,R.layout.abc,value));
          }
@Override
    protected void onListItemClick(ListView l, View v, int position, long id) {             
        super.onListItemClick(l, v, position, id);              

        // Get the item that was clicked
        //Object o = this.getListAdapter().getItem(position);       

       //Generate and display the List of visits for this day by calling the AsyncTask


        getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);               


        String keyword = value[position];

        mediaPlayer.reset();        
        try
        {
            mediaPlayer.setDataSource("/sdcard/"+keyword+".mp4");
            mediaPlayer.prepare();
            mediaPlayer.start();                            
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

If is there any way to do it please help me.

Upvotes: 0

Views: 4179

Answers (1)

bHaRaTh
bHaRaTh

Reputation: 3524

Following these steps may help you.

  1. Place a TextView in each row of the ListView.

  2. once any particular row is clicked , you can strike the TextView of that particular row.

    so how to strike the TextView? to answer this question , you can use this link Is there an easy way to strike through text in an app widget?

Upvotes: 2

Related Questions