一旦项目被选中,如何删除列表视图的文本

时间:2011-04-08 10:44:22

标签: android listview checkedtextview

我有几个项目CheckedTextView。一旦我选择列表,我想让文本删除,当我重新加载我的应用程序时它必须删除 我的xml包含以下代码

<?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"  
/>

我的活动包含以下代码:

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();
        }
    }

如果有任何办法可以帮助我。

1 个答案:

答案 0 :(得分:2)

遵循这些步骤可能会对您有所帮助。

  1. ListView的每一行放置一个TextView。

  2. 点击任何特定行后,您可以点击该特定行的TextView

    那么如何打击TextView?要回答此问题,您可以使用此链接Is there an easy way to strike through text in an app widget?