hi all,
I am creating an application in which i used a List view to list all
files present in SD card, but for some purpose i need to make ListView
checkable or selectable by user.
i created my own Array adapter of Files, i tried getChoiceMode
property as Multiselection but its not working. can someone help me in
correcting my code if there is any missing thing.
ListView listFiles;
FileAdapter adapter;
File[] files; // Full path to the files
File file; // Current file
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.filelist);
Home = this.getFilesDir();
// Finding Buttons for listing files
btnBack = (Button)findViewById(R.id.btnBack);
btnBack.setOnClickListener(this);
btnSDCard = (Button)findViewById(R.id.btnSDCard);
btnSDCard.setOnClickListener(this);
btnHome = (Button)findViewById(R.id.btnHome);
btnHome.setOnClickListener(this);
btnRoot = (Button)findViewById(R.id.btnRoot);
btnRoot.setOnClickListener(this);
listFiles = (ListView)findViewById(R.id.listFiles);
listFiles.setOnItemClickListener(this);
listFiles.setAdapter(new
ArrayAdapter<File>(this,android.R.layout.simple_list_item_multiple_choice,files));
adapter = new FileAdapter(this,files);
listFiles.setAdapter(adapter);
listFiles.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
}
When i am running this code its giving Null Pointer exception,can
someone help me how i rectify or correct this problem.
Thanks
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en