jeudi 16 avril 2015

Java ArrayAdaptor Crashing


Vote count:

0




Alright. For some reason I am getting a null pointer exception when trying to setup an ArrayAdaptor. Can someone take a look and see whats wrong with this?



public class FragmentTab1 extends ListFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState){
final List<String> fileNames = jpgFiles(getExternalFilesDir(null) + "/");
super.onCreate(savedInstanceState);
//setContentView(R.layout.familytab);
View view = inflater.inflate(R.layout.familytab, container, false);
ArrayAdapter<String> codeLearnArrayAdapter = new ArrayAdapter<String>(TestMediaView.this, android.R.layout.simple_list_item_1, fileNames);
final ListView codeLearnLessons = (ListView)findViewById(R.id.familylist);
codeLearnLessons.setAdapter(codeLearnArrayAdapter);
codeLearnLessons.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
//final String text = ((TextView)view).getText();
//String text = codeLearnLessons.get(position).tostring().trim();//first method
String text = fileNames.get(position);
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File(getExternalFilesDir(null) + "/" + codeLearnLessons.getItemAtPosition(position).toString());
intent.setDataAndType(Uri.fromFile(file), "image/*");
startActivity(intent);
}
});
return view;
}
}


The error occurs on this line " codeLearnLessons.setAdapter(codeLearnArrayAdapter);" Thanks



asked 1 min ago







Java ArrayAdaptor Crashing

Aucun commentaire:

Enregistrer un commentaire