我有一个只显示1张图片的应用,通过 $tbody[] = $row;
// Birth Day Section
$row = Form::label("year", _("Birth Date") . ":");
$aux = explode("-", ( !empty($formVar["birth_date"]) ) ? $formVar["birth_date"] : '0000-00-00');
$row .= Form::text("year",
(intval($aux[0]) != 0) ? intval($aux[0]) : null,
array('size' => 4)
);
$row .= " - ";
//$array = null;
$array['1'] = _("1");
$array['2'] = _("2");
$array['3'] = _("3");
$array['4'] = _("4");
$array['5'] = _("5");
$array['6'] = _("6");
$array['7'] = _("7");
$array['8'] = _("8");
$array['9'] = _("9");
$array['10'] = _("10");
$array['11'] = _("11");
$array['12'] = _("12");
$row .= Form::select("month", $array, $formVar["month"]);
//unset($array);
$row .= " - ";
$row .= Form::text("day",
(intval($aux[2]) != 0) ? intval($aux[2]) : null,
array('size' => 2)
);
$row .= " " . _("(yyyy-mm-dd)");
unset($aux);
if ($formError["birth_date"] != "")
{
$row .= Msg::error($formError["birth_date"]);
}
实现。如果我用简单的toast替换内容,Picasso
工作正常,所以它必须是onClick
调用。我不知道它为什么会一直崩溃。
MediaPlayer
}
XML:
package com.example.andrew.crossfade;
import android.media.MediaPlayer;
import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.squareup.picasso.Picasso;
public class MainActivity extends ActionBarActivity{
MediaPlayer mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
setContentView(R.layout.activity_main);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new PlaceholderFragment())
.commit();
}
ImageView imageView = (ImageView) findViewById(R.id.imageView);
imageView.setClickable(true);
Picasso.with(this)
.load("http://i.imgur.com/vpeH7S2.jpg")
.into(imageView);
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mp = MediaPlayer.create(MainActivity.this, R.raw.later);
mp.start();
}
});
}
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
return rootView;
}
}
最后,日志猫:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container"
android:layout_width="match_parent" android:layout_height="match_parent"
tools:context=".MainActivity" tools:ignore="MergeRootFrame" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
/>
答案 0 :(得分:1)
代码中的某些内容为空
显示java.lang.NullPointerException
在开始之前调用mp.prepare() 并确保R.raw.later是媒体播放器的可播放音频