java - Unable to populate ListView with ArrayList -


I'm trying to create an audio record for which I still want to display the list of recordings.

I am able to get the file from my SD card recorded in an ArrayList list, but my app crashes while trying to fill this list view.

ListRecordings.java is called using one. MainActivity.java means

here for ListRecordings.java:

  spreads the public category ListRecordings activity {@Override protected Zero onCreate (bundled savedInstanceState) {setContentView (R. Layout.listrecordings); List view lv; String path = environment .getExternalStorageDirectory () .getAbsolutePath () + "/ MyAudioRecorder"; ArrayList & LT; String & gt; FilesInFolder = GetFiles (Path); Lv = (ListView) findViewById (R.id.filelist); ArrayAdapter & LT; String & gt; Adapter = new array adapter & lt; String & gt; (This, R.Lettextstyle, File Inf Folder); Lv.setAdapter (adapter); Lv.setOnItemClickListener (New AdapterView.OnItemClickListener () {Public Zero onItemClick (AdapterView & LT;?> Parents, View V, Integer Status, Long ID) {// clicking on the item}}); } Public Array List & lt; String & gt; GetFiles (string directory) {ArrayList & lt; String & gt; MyFile = New Arrestist & lt; String & gt; (); File f = new file (directory); F.mkdirs (); File [] files = f.listFiles (); If (files.length == 0) return tap; Else {for (int i = 0; i & lt; files.length; i ++) MyFiles.add (files [i] .getName ()); } Return to MyFile; }}   

listrecordings.xml

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; LinearLayout xmlns: android = "Http://schemaskandroidkcom/apk/res/android" Android: Layout_width = "Match_parent" Android: Layout_height = "Match_parent" android: orientation = "vertical" & gt; & Lt; ListView Android: id = "@ + id / filelist" Android: layout_width = "match_parent" Android: layout_height = "wrap_content" & gt; & Lt; / ListView & gt; & Lt; / LinearLayout & gt;   

textlayout.xml

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; TextView xmlns: Android = "http://schemas.android.com/apk/res/android" Android: ID = "@ + ID / Label" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" Android: Padding = "10dp" Android: textSize = "16sp" Android: textStyle = "bold" & gt; & Lt; / TextView & gt;   

Any help is appreciated.

I just started with Android, so please forgive me if I made any lame mistakes.

Thank you

text

missing this line in onCreate ()

  super.onCreate (savedInstanceState);    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -