我正在尝试使用SwipeListView
,但是当我触摸我的应用程序上的某个项目时,它会崩溃,日志信息在那里:
05-26 21:52:26.545: E/AndroidRuntime(19862): java.lang.NullPointerException
05-26 21:52:26.545: E/AndroidRuntime(19862): at com.fortysevendeg.android.swipelistview.SwipeListViewTouchListener.setFrontView(SwipeListViewTouchListener.java:121)
05-26 21:52:26.545: E/AndroidRuntime(19862): at com.fortysevendeg.android.swipelistview.SwipeListViewTouchListener.onTouch(SwipeListViewTouchListener.java:485)
05-26 21:52:26.545: E/AndroidRuntime(19862): at com.fortysevendeg.android.swipelistview.SwipeListView.onInterceptTouchEvent(SwipeListView.java:481)
我一步一步地使用它
import android.app.Activity;
import android.os.Bundle;
import com.fortysevendeg.android.swipelistview.SwipeListView;
import com.mkyong.android.adaptor.MobileArrayAdapter;
public class ListMobileActivity extends Activity {
static final String[] MOBILE_OS = new String[] { "Android", "iOS",
"WindowsMobile", "Blackberry"};
MobileArrayAdapter myad ;
private SwipeListView swipeListView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainactivity);
swipeListView =(SwipeListView)findViewById(R.id.book_listview);
myad=new MobileArrayAdapter(this, MOBILE_OS);
swipeListView.setAdapter(myad);
}
}
这是我的布局文件
<?xml version="1.0" encoding="UTF-8"?>
android:id="@+id/LinearLayoutListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF" >
xmlns:swipe="http://schemas.android.com/apk/res-auto"
android:id="@+id/book_listview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:listSelector="#00000000"
swipe:swipeActionLeft="dismiss"
swipe:swipeBackView="@+id/back"
swipe:swipeCloseAllItemsWhenMoveList="true"
swipe:swipeFrontView="@+id/front"
swipe:swipeMode="both" />
有什么我想念的吗?谢谢