run メソッドでダイアログが表示されないのはなぜでしょうか。arraylist にファイルが追加されるかどうかさえ疑問です。ダイアログボックスを表示するためにハンドラーを使用する必要があるかもしれませんが、ここにハンドラーを組み込むにはどうすればよいですか plz ガイド.
public class Homescreen extends Activity implements OnClickListener, Runnable {
ImageButton play, repeat, previous, next, playlist, shuffle, playlister1;
Intermediate inter;
ListView LVSongs;
Toast t1;
ArrayAdapter<String> songsAdapter;
Thread t;
Handler handler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.homescreen);
initialize();
initializeListeners();
LVSongs.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
}
});
}
private void initializeListeners() {
// TODO Auto-generated method stub
play.setOnClickListener(this);
repeat.setOnClickListener(this);
previous.setOnClickListener(this);
shuffle.setOnClickListener(this);
playlist.setOnClickListener(this);
next.setOnClickListener(this);
playlister1.setOnClickListener(this);
}
private void initialize() {
// TODO Auto-generated method stub
play = (ImageButton) findViewById(R.id.IBPlay);
repeat = (ImageButton) findViewById(R.id.IBRepeat);
previous = (ImageButton) findViewById(R.id.IBPrevious);
next = (ImageButton) findViewById(R.id.IBNext);
playlist = (ImageButton) findViewById(R.id.IBPlaylist);
shuffle = (ImageButton) findViewById(R.id.IBShuffle);
LVSongs = (ListView) findViewById(R.id.LVplaylist);
songsAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, Serviceman.songs);
LVSongs.setAdapter(songsAdapter);
playlister1 = ((ImageButton) findViewById(R.id.IBPlaylist1));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.homescreen, menu);
return true;
}
@Override
public void onClick(View clickedVariable) {
// TODO Auto-generated method stub
switch (clickedVariable.getId()) {
case R.id.IBPlay:
break;
case R.id.IBNext:
break;
case R.id.IBPrevious:
break;
case R.id.IBPlaylist:
break;
case R.id.IBRepeat:
break;
case R.id.IBShuffle:
break;
case R.id.IBPlaylist1:
Intent playlist = new Intent(getApplicationContext(),
playlist.class);
startActivity(playlist);
}
}
@Override
public void run() {
// TODO Auto-generated method stub
// HashMap<String, String> song;
Uri allsongsuri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
String[] STAR = { "*" };
String selection = MediaStore.Audio.Media.IS_MUSIC + " != 0";
@SuppressWarnings("deprecation")
Cursor cursor = managedQuery(allsongsuri, STAR, selection, null, null);
ProgressDialog dialog = new ProgressDialog(Homescreen.this,
android.R.style.Animation_Translucent);
dialog.setMax(100);
try {
if (cursor != null) {
if (cursor.moveToFirst()) {
do {
dialog.show();
// song = new HashMap<String, String>();
// SongName
String song_name = cursor
.getString(cursor
.getColumnIndex(MediaStore.Audio.Media.DISPLAY_NAME));
dialog.setMessage(song_name);
// path
String fullpath = cursor.getString(cursor
.getColumnIndex(MediaStore.Audio.Media.DATA));
Serviceman.songs.add(song_name);
songsAdapter.notifyDataSetChanged();
dialog.incrementProgressBy(5);
} while (cursor.moveToNext());
dialog.dismiss();
}
}
} catch (NullPointerException exp) {
Log.e("~~Null Pointer Exception~~", exp.toString());
android.util.Log.e("->>", "~~stacktrace~~", exp);
} catch (Exception exp) {
Log.e("~~Exception~~", exp.toString());
}
}