我正在使用Sugar ORM来持久保存和检索数据.下面是我用来存储和检索数据的代码.
Slider.deleteAll(Slider.class);
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, Constants.URL, jsonRepos.getSliderJobj(),
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Log.d(Constants.MAINACTIVITY,response.toString());
try {
JSONArray sliderArray = response.getJSONArray("slider");
for (int i=0; i<sliderArray.length(); i++){
JSONObject sliderArrayJSONObject = sliderArray.getJSONObject(i);
String id = sliderArrayJSONObject.getString("id");
String albumId = sliderArrayJSONObject.getString("album_id");
String title = sliderArrayJSONObject.getString("title");
String imgUrl = sliderArrayJSONObject.getString("img_url");
String file = sliderArrayJSONObject.getString("file");
Log.d(Constants.MAINACTIVITY,file);
Log.d("Note", "saving");
Slider slider = new Slider(id, albumId, title , file, imgUrl);
slider.save();
}
catch (JSONException e) {
e.printStackTrace();
}
}
},
appController.getErrorListener()
); …Run Code Online (Sandbox Code Playgroud) 我在重复当前歌曲的onCompletion听众中使用以下代码MediaPlayer。
if (isRepeat) {
if (mMediaPlayer.isPlaying()) {
mMediaPlayer.stop();
mMediaPlayer.reset();
}
try {
mMediaPlayer.setDataSource(MainActivity.localTrackList.get(MainActivity.currentOffset).getPath());
mMediaPlayer.prepareAsync();
} catch (IOException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误消息,
at android.media.MediaPlayer._setDataSource(Native Method)
09-15 09:05:19.884 12545-12545/ W/System.err: at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1115)
09-15 09:05:19.884 12545-12545/ W/System.err: at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1100)
09-15 09:05:19.884 12545-12545/ W/System.err: at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1079)
09-15 09:05:19.884 12545-12545/ W/System.err: at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1028)
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
我试图动画"Loading ..."textview的三个点,如下所示,
Handler handler = new Handler();
for (int i = 100; i <= 3500; i =i+100) {
final int finalI = i;
handler.postDelayed(new Runnable() {
@Override
public void run() {
if(finalI %300 == 0){
loadigText.setText("Loading.");
}else if(finalI %200 == 0){
loadigText.setText("Loading..");
}else if(finalI %100 == 0){
loadigText.setText("Loading...");
}
}
}, i);
Run Code Online (Sandbox Code Playgroud)
问题是,1.我无法动画它,直到对话框可见.我无法降低三点动画的速度,
我怎样才能解决这个问题
我使用以下代码创建一个折叠工具栏,其中包含listview.
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="@dimen/detail_backdrop_height"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:expandedTitleTextAppearance="@android:color/transparent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/backdrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/love_music"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/backdrop_title"
android:textColor="@android:color/white"
android:textSize="@dimen/backdrop_title" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/backdrop_subtitle"
android:textColor="@android:color/white"
android:textSize="@dimen/backdrop_subtitle" />
</LinearLayout>
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<include layout="@layout/activity_experience"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@+id/appbar" />
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
问题是,listview与appbar布局重叠,因此listview出现在appbarlayout中.布局activity_experience …