小编dii*_*iz_的帖子

如何将XML反序列化为JavaScript/TypeScript?

我得到一个XML结构,其中包含有关约会的信息.

我的代码:

function AppointmentCallback(appointment : any) {
}
Run Code Online (Sandbox Code Playgroud)

我想在JavaScript或TypeScript(首选)中的对象中转换它.在jQuery中,只有与parseXML我需要的方法相反的方法.

是否有任何图书馆可以实现这一目标?

提前致谢!

javascript xml parsing deserialization typescript

9
推荐指数
1
解决办法
2万
查看次数

工具栏 - findViewbyID返回null

为什么我无法找到我Toolbar的布局?

setContentView(R.layout.activity_main);

toolbar = (Toolbar) findViewById(R.id.toolbar);
if (toolbar != null) {
    setSupportActionBar(toolbar);
    getSupportActionBar().setHomeButtonEnabled(true);
}
Run Code Online (Sandbox Code Playgroud)

之后,工具栏仍为空.

activity_man.xml:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipToPadding="false"
    tools.context=".PlayerActivity">

    <include
        android:id="@+id/toolbar"
        layout="@layout/toolbar"/>
    <ImageView
        android:id="@+id/background_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="centerCrop"/>
        : (goes on)
Run Code Online (Sandbox Code Playgroud)

编辑:

toolbar.xml:

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"/>
Run Code Online (Sandbox Code Playgroud)

谢谢!

android toolbar android-5.0-lollipop

9
推荐指数
1
解决办法
8308
查看次数

Android MediaPlayer错误(-38,0)

我的媒体播放器出了问题.有时会发生错误并调用on错误.我有Mediaplayer和两个int作为参数.第一个int是"-38",第二个是"0".

那是什么意思?

编辑:代码:http://pastebin.com/3XBaFYwF

这是我的logcat @Blundell LogCat:

http://pastebin.com/Wbjm3QCW

android android-mediaplayer

5
推荐指数
1
解决办法
9047
查看次数

为什么我得到一个null.p.ex。在startForegrund上?

我想发出一个通知来控制我的音乐播放器,所以我想启动一个前台服务。

我的代码:

@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
protected void onStop(){
    super.onStop();
    System.out.println("Stop");
    Toast.makeText(this,"Stopped",Toast.LENGTH_SHORT).show();
    if(play_media.isPlaying()){
        PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0,
                new Intent(getApplicationContext(), MainActivity.class),
                PendingIntent.FLAG_UPDATE_CURRENT);
        Notification notification = new Notification.Builder(mContext)
                .setContentTitle("Playing")
                .setContentText("playing a song")
                .setSmallIcon(R.drawable.ic_play)
                .setLargeIcon(list.get(mDrawerList.getCheckedItemPosition()).getAlbum_Art())
                .setContentIntent(pi)
                .build();

        mediaPlayerService =  new MediaPlayerService();
 322:       mediaPlayerService.startForeground(NOTIFICATION_ID,notification);
    }
}
Run Code Online (Sandbox Code Playgroud)

在startForeground上捕获到异常:

02-12 18:06:08.935    4405-4405/? E/AndroidRuntime? FATAL EXCEPTION: main
Process: com.Driiinx.musicslide, PID: 4405
java.lang.RuntimeException: Unable to stop activity {...com.Driiinx.musicslide.MainActivity}: java.lang.NullPointerException: class name is null
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3188)
Run Code Online (Sandbox Code Playgroud)

...

Caused by: java.lang.NullPointerException: class name is null
        at android.content.ComponentName.<init>(ComponentName.java:63)
        at android.app.Service.startForeground(Service.java:643)
        at com.Driiinx.musicslide.MainActivity.onStop(MainActivity.java:322)
Run Code Online (Sandbox Code Playgroud)

谢谢!

android media-player

4
推荐指数
1
解决办法
952
查看次数