【发布时间】:2017-02-26 08:15:40
【问题描述】:
我正在尝试调用此方法
public void get() {
tileView.smoothScaleFromCenter( 0.5000f );
}
在我的基本活动中的onItemClick 中,但它崩溃了。我该如何解决这个问题?
这是我的基本活动:
public boolean onQueryTextChange(String newText) {
showResults(newText + "*");
return false;
}
public boolean onQueryTextSubmit(String query) {
showResults(query + "*");
return false;
}
public boolean onClose() {
searchView.onActionViewCollapsed();
showResults("");
return false;
}
private void showResults(String query) {
Cursor cursor = mDbHelper.searchPlaces((query != null ? query.toString() : "@@@@"));
if (cursor == null) {
//
} else {
// Specify the columns we want to display in the result
String[] from = new String[]{
PlacesDbAdapter.KEY_PLACES
};
// Specify the Corresponding layout elements where we want the columns to go
int[] to = new int[]{R.id.scustomer
};
// Create a simple cursor adapter for the definitions and apply them to the ListView
SimpleCursorAdapter places1 = new SimpleCursorAdapter(this, R.layout.customerresult, cursor, from, to);
mListView.setAdapter(places1);
// Define the on-click listener for the list items
mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
new MainActivity().get();
searchView.setQuery("", true);
}
});
}
}
这是我的主要活动:
public void get() {
tileView.smoothScaleFromCenter( 0.5000f );
}}
这是我的日志:
02-26 16:12:21.074 31567-31567/com.example.lightning.myapplication3 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.lightning.myapplication3, PID: 31567
java.lang.NullPointerException
at com.example.lightning.myapplication3.MainActivity.get(MainActivity.java:208)
at com.example.lightning.myapplication3.BaseActivity$3.onItemClick(BaseActivity.java:197)
at android.widget.AdapterView.performItemClick(AdapterView.java:299)
at android.widget.AbsListView.performItemClick(AbsListView.java:1156)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:2963)
at android.widget.AbsListView$3.run(AbsListView.java:3737)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5421)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:979)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:795)
at dalvik.system.NativeStart.main(Native Method)
【问题讨论】:
标签: android searchview