更新
logcat的:
02-29 23:48:17.149: E/AndroidRuntime(520): android.content.res.Resources$NotFoundException: String resource ID #0xabe0
02-29 23:48:17.149: E/AndroidRuntime(520): at android.content.res.Resources.getText(Resources.java:201)
02-29 23:48:17.149: E/AndroidRuntime(520): at android.widget.TextView.setText(TextView.java:2857)
02-29 23:48:17.149: E/AndroidRuntime(520): at net.website.qty.mediaplayer.Main.onListItemClick(Main.java:441)
02-29 23:48:17.149: E/AndroidRuntime(520): at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
02-29 23:48:17.149: E/AndroidRuntime(520): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
02-29 23:48:17.149: E/AndroidRuntime(520): at android.widget.ListView.performItemClick(ListView.java:3513)
02-29 23:48:17.149: E/AndroidRuntime(520): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1812)
02-29 23:48:17.149: E/AndroidRuntime(520): at android.os.Handler.handleCallback(Handler.java:587)
02-29 23:48:17.149: E/AndroidRuntime(520): at android.os.Handler.dispatchMessage(Handler.java:92)
02-29 23:48:17.149: E/AndroidRuntime(520): at android.os.Looper.loop(Looper.java:123)
02-29 23:48:17.149: E/AndroidRuntime(520): at android.app.ActivityThread.main(ActivityThread.java:3683)
02-29 23:48:17.149: E/AndroidRuntime(520): at java.lang.reflect.Method.invokeNative(Native Method)
02-29 23:48:17.149: E/AndroidRuntime(520): at java.lang.reflect.Method.invoke(Method.java:507)
02-29 23:48:17.149: E/AndroidRuntime(520): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-29 23:48:17.149: E/AndroidRuntime(520): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-29 23:48:17.149: E/AndroidRuntime(520): at dalvik.system.NativeStart.main(Native Method)
我正在开发一个流音频歌曲的应用程序,所以我试图显示该音频歌曲的总持续时间,这是我到目前为止所做的但无济于事。我跟着这个link,但仍然无法。
private TextView tv_mediaFileLengthInMilliseconds = null;
MediaPlayer player;
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
...........
...........
tv_mediaFileLengthInMilliseconds = (TextView)findViewById(R.id.duration);
tv_mediaFileLengthInMilliseconds.setText(player.getDuration());
}
布局:
<TextView
android:id="@+id/duration"
android:layout_width="136dp"
android:layout_height="wrap_content"
android:ellipsize="middle"
android:gravity="center_horizontal"
android:singleLine="true"
android:textColor="@android:color/black" />