I'm creating an application similar to the link given here, where it shows three images transition from one state to another when click.
1) Stage 1: When a series of listview of video files are stored in a video directory. How do i create this particular view into the ListView?
2) Stage 2: When a video file is being click it does not immediately play the video instead it shows a dialog box showing the detail of the file.
3) Stage 3: The user could either Exit, Select Play video or show roadmap details...
Could someone help me i'm kinna new in android/java here, i'm tot开发者_如何学JAVAally lost on how to start creating the above views like how do i populate the Listview with existing video files found in my video directory?
You realize that your basically asking someone to make the application for you? In any case, I shall try to give you some help to get started.
Stage 1: Do you know how to create a ListView? Here's an example:
listView = (ListView) findViewById(R.id.list_view);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, elements); //elements is a List<String>
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//What to do when an item is clicked
}
});
You can customize the look of the list items by creating a XML-file containing a single TextView and then use that when creating the ArrayAdapter (like R.layout.list_item).
If you want a completely custom View, like in the app in the link, you can create your own adapter and then implementing the View getView(int position, View convertView, ViewGroup parent)
function, where you return the View you want to be displayed.
Example:
View row = convertView;
if (row == null) {
LayoutInflater mInflater = LayoutInflater.from(getContext());
row = mInflater.inflate(R.layout.bookings_list_item, parent, false);
}
return row;
You can create the elements list by counting the files in the video directory. I don't really know how to do this, but it shouldn't be too hard. Perhaps someone else can provide you with an answer if you don't find out yourself.
Stage 2: Implement this in the OnItemClickListener in the example above by showing a dialog.
Stage 3: Implement what the Dialog will do when it's buttons are pressed. Exit: dismiss popup. Play video: Launch an intent to a video player. I'm not sure about how to show roadmap details, but you can always use Google Maps in your app (there's a sample here).
Now, I hope you can get something useful from this. I hope I have provided you with enough details to be able to get started with researching and a little coding. :)
精彩评论