I am working on a sound recorder app. I have made the app so that it properly records mp3 files and saves them. Now I want to make it to be able to display the recordings and after they are clicked to start up a custom dialog in which the user can play the file, pause, or move the progress bar...
This is what I basically want to achieve here:
This is what I have at the moment:
I would like to populate the ListFragment with mp3 files from a specific directory. So basically list files from SDCard in ListFragment.
public class TwoFragment extends ListFragment implements AdapterView.OnItemClickListener{
public TwoFragment() {
// Required empty public constructor
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_two, container, false);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
ArrayAdapter adapter = ArrayAdapter.createFromResource(getActivity(), R.array.heroes, android.R.layout.simple_list_item_1);
setListAdapter(adapter);
getListView().setOnItemClickListener(this);
}
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l){
Toast.makeText(getActivity(), "Item " + i, Toast.LENGTH_SHORT).show();
}
}
And this is the xml file for FragmentTwo
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<TextView
android:id="@android:id/empty"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TextView>
</LinearLayout>
I am kinda lost at the moment, I have tried googling, haven't really made any progress as I don't know how to properly "link"(?) the files from sdcard to display in ListView. I should probably do something with the Adapter but I'm not sure. Thanks for any help!