我试图调用此方法从另一个活动调用方法崩溃
public void get() {
tileView.smoothScaleFromCenter(0.5000f);
}
我onItemClick
从我baseactivity,但它崩溃。我怎样才能解决这个问题?
这是我baseactivity:
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);
}
});
}
}
这是我mainactivity:
public void get() {
tileView.smoothScaleFromCenter(0.5000f);
}}
这里是我的logcat:
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)
我不明白一点。你能告诉我如何做到这一点。?对不起我即将新手 – madara09
编辑我的答案,看看 –
非常感谢。 – madara09