I have found plenty of ways to do that, none of them simple, though (and I wasn t able to implement the more complicated one, so I am looking for a simpler solution). I would like to fill my ArrayAdapter with the names of all png files in my direcory I use for saving some pngs from the app. This one is great:http://www.dreamincode.net/forums/topic/190013-creating-simple-file-chooser/ but not exactly easy. I believe there is a simpler way, I just couldn t find it (and I really did my homework and was looking for it quite some time). I assume something like File.listFiles() could work, I just don t know how.
我的代码:
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
String[] values = new String[] ;
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, values);
setListAdapter(adapter);
getListView().setBackgroundDrawable(getResources().getDrawable(R.drawable.diver));
}
@Override
protected void onListItemClick(ListView list, View v, int position, long id) {
list.setBackgroundDrawable(getResources().getDrawable(R.drawable.diver));
String item = (String) getListAdapter().getItem(position);
setContentView(R.layout.table);
myWebView = (WebView)findViewById(R.id.myWebView);
myWebView.setInitialScale(50);
myWebView.getSettings().setBuiltInZoomControls(true);
myWebView.loadUrl(Environment.getExternalStorageDirectory()+ File.separator + "DivePlanner" + File.separator + item);
}
我要填入目录 / sdcard/ DivePlanner / 中所有 png 文件的名称。 如果有人知道任何容易的方法, 非常感谢!