我的应用程序在Android 2.3上运行时崩溃,但在Android 4.0中它运行正常。这发生在一个活动中:简单的文本视图,没有特定的库。为什么?我该如何解决这个问题?这是错误日志:
03-23 01:01:37.379: D/testService(2126): Sto per lanciare il servizio
03-23 01:01:37.389: W/dalvikvm(2126): VFY: unable to resolve virtual method 4279: Lnet/simonvt/widget/BuildLayerFrameLayout;.setTranslationX (F)V
03-23 01:01:37.389: W/dalvikvm(2126): VFY: unable to resolve virtual method 4279: Lnet/simonvt/widget/BuildLayerFrameLayout;.setTranslationX (F)V
03-23 01:01:37.399: W/dalvikvm(2126): VFY: unable to resolve virtual method 4277: Lnet/simonvt/widget/BuildLayerFrameLayout;.setLayerType (ILandroid/graphics/Paint;)V
03-23 01:01:37.399: W/dalvikvm(2126): VFY: unable to resolve virtual method 2928: Landroid/view/ViewGroup;.postOnAnimation (Ljava/lang/Runnable;)V
03-23 01:01:37.399: W/dalvikvm(2126): VFY: unable to resolve virtual method 4277: Lnet/simonvt/widget/BuildLayerFrameLayout;.setLayerType (ILandroid/graphics/Paint;)V
03-23 01:01:37.439: V/testService(2126): Caricamento: false
03-23 01:01:44.609: V/testService(2126): position: 0
03-23 01:01:44.879: W/dalvikvm(2126): Link of class 'Ltest/testservicedown/CrociereDestActivity;' failed
03-23 01:01:44.879: E/dalvikvm(2126): Could not find class 'test.testservicedown.CrociereDestActivity', referenced from method test.testservicedown.MainActivity$4.onItemClick
03-23 01:01:44.879: W/dalvikvm(2126): VFY: unable to resolve const-class 1248 (Ltest/testservicedown/CrociereDestActivity;) in Ltest/testservicedown/MainActivity$4;
03-23 01:01:47.589: W/dalvikvm(2126): threadid=1: thread exiting with uncaught exception (group=0x40126560)
03-23 01:01:47.599: E/AndroidRuntime(2126): FATAL EXCEPTION: main
03-23 01:01:47.599: E/AndroidRuntime(2126): java.lang.NoClassDefFoundError: test.testservicedown.CrociereDestActivity
03-23 01:01:47.599: E/AndroidRuntime(2126): at test.testservicedown.MainActivity$4.onItemClick(MainActivity.java:429)
03-23 01:01:47.599: E/AndroidRuntime(2126): at android.widget.AdapterView.performItemClick(AdapterView.java:284)
03-23 01:01:47.599: E/AndroidRuntime(2126): at android.widget.ListView.performItemClick(ListView.java:3744)
03-23 01:01:47.599: E/AndroidRuntime(2126): at android.widget.AbsListView$PerformClick.run(AbsListView.java:1991)
03-23 01:01:47.599: E/AndroidRuntime(2126): at android.os.Handler.handleCallback(Handler.java:587)
03-23 01:01:47.599: E/AndroidRuntime(2126): at android.os.Handler.dispatchMessage(Handler.java:92)
03-23 01:01:47.599: E/AndroidRuntime(2126): at android.os.Looper.loop(Looper.java:130)
03-23 01:01:47.599: E/AndroidRuntime(2126): at android.app.ActivityThread.main(ActivityThread.java:3687)
03-23 01:01:47.599: E/AndroidRuntime(2126): at java.lang.reflect.Method.invokeNative(Native Method)
03-23 01:01:47.599: E/AndroidRuntime(2126): at java.lang.reflect.Method.invoke(Method.java:507)
03-23 01:01:47.599: E/AndroidRuntime(2126): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
03-23 01:01:47.599: E/AndroidRuntime(2126): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
03-23 01:01:47.599: E/AndroidRuntime(2126): at dalvik.system.NativeStart.main(Native Method)
CrociereDestActivity:
package test.testservicedown;
import java.util.ArrayList;
import java.util.List;
import test.testservicedown.models.Crociera;
import test.testservicedown.models.ListAdapter;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.ActionBar;
import android.app.Activity;
import android.app.SearchManager;
import android.content.Intent;
import android.database.Cursor;
import android.database.DataSetObserver;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SearchView;
import android.widget.SearchView.OnQueryTextListener;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;
public class CrociereDestActivity extends Activity implements OnQueryTextListener{
private static final String TAG = "testService";
private String pkg;
private String zona;
private String period;
private String query;
private String prezzo;
private String nome;
private List<String> listaPromo;
private String from1[] = { "*,substr(a.departure_date, -2,2) ||'_'||substr(a.departure_date, -5,2) ||'_'|| substr(a.departure_date, -8,2) as data"};
private String from[] = {"*"};
private String fromMSCDest[] = {"_id", "code", "name"};
private String fromMSC[] = {"cruise_id", "departure_date", "itinerary_desc", "minimum_price", "nights_number", "departure_port_id", "destination_id", "period_id"};
private String fromMSCItin[] = {"cruise_id", "day_number", "departure_date", "departure_time", "arrival_date", "arrival_day_number", "arrival_time", "arrival_port_id", "departure_port_id"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.lista_crociere);
Intent intent = getIntent();
pkg = getPackageName();
zona = intent.getStringExtra(pkg + "ZONA");
query = intent.getStringExtra(pkg + "QUERY");
period = intent.getStringExtra(pkg + "PERIOD");
prezzo = intent.getStringExtra(pkg + "PREZZO");
nome = intent.getStringExtra(pkg + "NOME");
setTitle("Crociere");
// Carica Promo-----------------------------------------
listaPromo = new ArrayList<String>();
String[] from = {"*"};
String where = "cruise_id IN (SELECT c.cruise_id FROM msc_cabin c LEFT OUTER JOIN msc_promos p ON c.cabin_id = p.cabin_id WHERE c.cabin_id = p.cabin_id GROUP BY c.cruise_id) GROUP BY d.name";
Cursor cPromo = null;
cPromo = getContentResolver().query(ServiceContentProvider.TABLE13_14_CONTENT_URI_PROMO, from, where, null, null);
while (cPromo.moveToNext()) {
String cruise_id = cPromo.getString(0);
listaPromo.add(cruise_id);
}
cPromo.deactivate();
cPromo.close();
if (query.equals("dest")) {
caricaDati();
} else if (query.equals("data")) {
caricaDatiData();
} else if (query.equals("prezzo")) {
caricaDatiPrezzo();
} else if (query.equals("depar")) {
caricaDatiPartenza();
} else if (query.equals("promo")) {
caricaDatiPromo();
}
}
private void caricaDati(){
List<Crociera>lstCrociere = new ArrayList<Crociera>();
Cursor c = null;
c = getContentResolver().query(ServiceContentProvider.TABLE13_14_15_16_17_CONTENT_URI, from1, "d.name = '" + zona + "' GROUP BY a.cruise_id", null, "data ASC");
if (c.getCount() > 0) {
while (c.moveToNext()) {
Crociera crociera = new Crociera();
crociera.setCruiseId(c.getString(0));
crociera.setItinerario(c.getString(2));
crociera.setNomeNave(c.getString(8));
String prezzo = c.getString(3).replace(",", ".");
crociera.setPrezzo(Float.parseFloat(prezzo));
crociera.setNomePortoPartenza(c.getString(27));
crociera.setDataPartenza(c.getString(1));
crociera.setArrival_potr_id(c.getString(19));
crociera.setNomePortoArrivo("");
crociera.setDataArrivo("");
crociera.setGiorno(c.getString(1).substring(0,2));
crociera.setMese(crociera.getDataPartenza());
crociera.setnNotti(Integer.parseInt(c.getString(4)));
if (listaPromo.contains(crociera.getCruiseId())) {
crociera.setPromo(true);
Log.v(TAG, "Promo: " + crociera.getCruiseId());
}else {
crociera.setPromo(false);
}
lstCrociere.add(crociera);
}
}
c.deactivate();
c.close();
ListView lvCrociere = (ListView)findViewById(R.id.lvCrociere);
lvCrociere.setAdapter(new ListAdapter(this, R.layout.row_blog, lstCrociere));
lvCrociere.setOnItemClickListener(mItemClickListener);
}
private void caricaDatiData(){
List<Crociera>lstCrociere = new ArrayList<Crociera>();
Cursor c = null;
c = getContentResolver().query(ServiceContentProvider.TABLE13_14_15_16_17_CONTENT_URI, from, "m.name = '" + period + "' GROUP BY a.cruise_id", null, null);
if (c.getCount() > 0) {
while (c.moveToNext()) {
Crociera crociera = new Crociera();
crociera.setCruiseId(c.getString(0));
crociera.setItinerario(c.getString(2));
crociera.setNomeNave(c.getString(8));
String prezzo = c.getString(3).replace(",", ".");
crociera.setPrezzo(Float.parseFloat(prezzo));
crociera.setNomePortoPartenza(c.getString(27));
crociera.setDataPartenza(c.getString(1));
crociera.setArrival_potr_id(c.getString(19));
crociera.setNomePortoArrivo("");
crociera.setDataArrivo("");
crociera.setGiorno(c.getString(1).substring(0,2));
crociera.setMese(crociera.getDataPartenza());
crociera.setnNotti(Integer.parseInt(c.getString(4)));
if (listaPromo.contains(crociera.getCruiseId())) {
crociera.setPromo(true);
Log.v(TAG, "Promo: " + crociera.getCruiseId());
}else {
crociera.setPromo(false);
}
lstCrociere.add(crociera);
}
}
c.deactivate();
c.close();
ListView lvCrociere = (ListView)findViewById(R.id.lvCrociere);
lvCrociere.setAdapter(new ListAdapter(this, R.layout.row_blog, lstCrociere));
lvCrociere.setOnItemClickListener(mItemClickListener);
}
private void caricaDatiPrezzo(){
List<Crociera>lstCrociere = new ArrayList<Crociera>();
Cursor c = null;
c = getContentResolver().query(ServiceContentProvider.TABLE13_14_15_16_17_CONTENT_URI, from, "a.minimum_price = '" + prezzo + "' GROUP BY a.cruise_id", null, null);
if (c.getCount() > 0) {
while (c.moveToNext()) {
Crociera crociera = new Crociera();
crociera.setCruiseId(c.getString(0));
crociera.setItinerario(c.getString(2));
crociera.setNomeNave(c.getString(8));
String prezzo = c.getString(3).replace(",", ".");
crociera.setPrezzo(Float.parseFloat(prezzo));
crociera.setNomePortoPartenza(c.getString(27));
crociera.setDataPartenza(c.getString(1));
crociera.setArrival_potr_id(c.getString(19));
crociera.setNomePortoArrivo("");
crociera.setDataArrivo("");
crociera.setGiorno(c.getString(1).substring(0,2));
crociera.setMese(crociera.getDataPartenza());
crociera.setnNotti(Integer.parseInt(c.getString(4)));
if (listaPromo.contains(crociera.getCruiseId())) {
crociera.setPromo(true);
Log.v(TAG, "Promo: " + crociera.getCruiseId());
}else {
crociera.setPromo(false);
}
lstCrociere.add(crociera);
}
}
c.deactivate();
c.close();
ListView lvCrociere = (ListView)findViewById(R.id.lvCrociere);
lvCrociere.setAdapter(new ListAdapter(this, R.layout.row_blog, lstCrociere));
lvCrociere.setOnItemClickListener(mItemClickListener);
}
private void caricaDatiPartenza(){
List<Crociera>lstCrociere = new ArrayList<Crociera>();
Cursor c = null;
c = getContentResolver().query(ServiceContentProvider.TABLE13_14_15_16_17_CONTENT_URI, from1, "p.name = '" + nome + "' GROUP BY a.cruise_id", null, "data ASC");
if (c.getCount() > 0) {
while (c.moveToNext()) {
Crociera crociera = new Crociera();
crociera.setCruiseId(c.getString(0));
crociera.setItinerario(c.getString(2));
crociera.setNomeNave(c.getString(8));
String prezzo = c.getString(3).replace(",", ".");
crociera.setPrezzo(Float.parseFloat(prezzo));
crociera.setNomePortoPartenza(c.getString(27));
crociera.setDataPartenza(c.getString(1));
crociera.setArrival_potr_id(c.getString(19));
crociera.setNomePortoArrivo("");
crociera.setDataArrivo("");
crociera.setGiorno(c.getString(1).substring(0,2));
crociera.setMese(crociera.getDataPartenza());
crociera.setnNotti(Integer.parseInt(c.getString(4)));
if (listaPromo.contains(crociera.getCruiseId())) {
crociera.setPromo(true);
Log.v(TAG, "Promo: " + crociera.getCruiseId());
}else {
crociera.setPromo(false);
}
lstCrociere.add(crociera);
}
}
c.deactivate();
c.close();
ListView lvCrociere = (ListView)findViewById(R.id.lvCrociere);
lvCrociere.setAdapter(new ListAdapter(this, R.layout.row_blog, lstCrociere));
lvCrociere.setOnItemClickListener(mItemClickListener);
}
private void caricaDatiPromo(){
List<Crociera>lstCrociere = new ArrayList<Crociera>();
String where = " a.cruise_id IN (SELECT c.cruise_id FROM msc_cabin c LEFT OUTER JOIN msc_promos p ON c.cabin_id = p.cabin_id WHERE c.cabin_id = p.cabin_id GROUP BY c.cruise_id) AND d.name = '" + zona + "' GROUP BY a.cruise_id";
Cursor c = null;
c = getContentResolver().query(ServiceContentProvider.TABLE13_14_15_16_17_CONTENT_URI, from1, where, null, "data ASC");
if (c.getCount() > 0) {
while (c.moveToNext()) {
Crociera crociera = new Crociera();
crociera.setCruiseId(c.getString(0));
crociera.setItinerario(c.getString(2));
crociera.setNomeNave(c.getString(8));
String prezzo = c.getString(3).replace(",", ".");
crociera.setPrezzo(Float.parseFloat(prezzo));
crociera.setNomePortoPartenza(c.getString(27));
crociera.setDataPartenza(c.getString(1));
crociera.setArrival_potr_id(c.getString(19));
crociera.setNomePortoArrivo("");
crociera.setDataArrivo("");
crociera.setGiorno(c.getString(1).substring(0,2));
crociera.setMese(crociera.getDataPartenza());
crociera.setnNotti(Integer.parseInt(c.getString(4)));
crociera.setPromo(true);
lstCrociere.add(crociera);
}
}
c.deactivate();
c.close();
ListView lvCrociere = (ListView)findViewById(R.id.lvCrociere);
lvCrociere.setAdapter(new ListAdapter(this, R.layout.row_blog, lstCrociere));
lvCrociere.setOnItemClickListener(mItemClickListener);
}
private AdapterView.OnItemClickListener mItemClickListener = new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
Intent i = new Intent(arg1.getContext(), DetailsActivity.class);
TextView tvCruiseID = (TextView) arg1.findViewById(R.id.txtIDCrociera);
String cruiseId = tvCruiseID.getText().toString();
TextView tvItinerario = (TextView) arg1.findViewById(R.id.txtItinerario);
String itin = tvItinerario.getText().toString();
TextView tvNomeNave = (TextView) arg1.findViewById(R.id.txtNomeNave);
String nomeNave = tvNomeNave.getText().toString();
TextView tvAnno = (TextView) arg1.findViewById(R.id.txtAnno);
String anno = tvAnno.getText().toString();
TextView tvMese = (TextView) arg1.findViewById(R.id.txtMese);
String mese = tvMese.getText().toString();
TextView tvGiorno = (TextView) arg1.findViewById(R.id.txtGiorno);
String giorno = tvGiorno.getText().toString();
TextView tvNomePortoDep = (TextView) arg1.findViewById(R.id.txtPortoPart);
String nPortoDep = tvNomePortoDep.getText().toString();
TextView tvNomePortoArr = (TextView) arg1.findViewById(R.id.txtPortoArr);
String nPortoArr = tvNomePortoArr.getText().toString();
TextView tvDataDep = (TextView) arg1.findViewById(R.id.txtDataPartenza);
String dataDep = tvDataDep.getText().toString();
TextView tvDataArr = (TextView) arg1.findViewById(R.id.txtDataArrivo);
String dataArr = tvDataArr.getText().toString();
TextView tvNNotti = (TextView) arg1.findViewById(R.id.txtNNotti);
String nNotti = tvNNotti.getText().toString();
i.putExtra(pkg + "CRUISEID", cruiseId);
i.putExtra(pkg + "ITIN", itin);
i.putExtra(pkg + "NNAVE", nomeNave);
i.putExtra(pkg + "ANNO", anno);
i.putExtra(pkg + "MESE", mese);
i.putExtra(pkg + "GIORNO", giorno);
i.putExtra(pkg + "NPORTODEP", nPortoDep);
i.putExtra(pkg + "NPORTOARR", nPortoArr);
i.putExtra(pkg + "DATADEP", dataDep);
i.putExtra(pkg + "DATAARR", dataArr);
i.putExtra(pkg + "NNOTTI", nNotti);
startActivity(i);
}
};
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@SuppressLint("NewApi")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
if(android.os.Build.VERSION.SDK_INT < 11){
}else {
SearchView searchView = (SearchView) menu.findItem(R.id.menu_search).getActionView();
searchView.setOnQueryTextListener(this);
}
return super.onCreateOptionsMenu(menu);
}
public boolean onQueryTextChange(String newText) {
// TODO Auto-generated method stub
return false;
}
public boolean onQueryTextSubmit(String query1) {
Log.v(TAG, "Ricerca: " + query);
if (!query1.equals("")) {
ricerca(query1);
// if (query.equals("dest")) {
// ricerca(query1);
// } else if (query.equals("data")) {
// ricercaData(query1);
// } else if (query.equals("prezzo")) {
// ricercaPrezzo(query1);
// } else if (query.equals("depar")) {
// ricercaPartenza(query1);
// } else if (query.equals("promo")) {
// ricercaPromo(query1);
// }
}
return false;
}
private void ricerca(String query){
List<Crociera>lstCrociere = new ArrayList<Crociera>();
Cursor c = null;
// c = getContentResolver().query(ServiceContentProvider.TABLE13_14_15_16_17_CONTENT_URI, from, "d.name = '" + zona + "' AND a.itinerary_desc LIKE '%" + query + "%' GROUP BY a.cruise_id", null, null);
c = getContentResolver().query(ServiceContentProvider.TABLE13_14_15_16_17_CONTENT_URI, from, "a.itinerary_desc LIKE '%" + query + "%' OR a.ship_name LIKE '%" + query + "%' OR p.name LIKE '%" + query + "%' GROUP BY a.cruise_id", null, null);
if (c.getCount() > 0) {
while (c.moveToNext()) {
Crociera crociera = new Crociera();
crociera.setCruiseId(c.getString(0));
crociera.setItinerario(c.getString(2));
crociera.setNomeNave(c.getString(8));
String prezzo = c.getString(3).replace(",", ".");
crociera.setPrezzo(Float.parseFloat(prezzo));
crociera.setNomePortoPartenza(c.getString(27));
crociera.setDataPartenza(c.getString(1));
crociera.setArrival_potr_id(c.getString(19));
crociera.setNomePortoArrivo("");
crociera.setDataArrivo("");
crociera.setGiorno(c.getString(1).substring(0,2));
crociera.setMese(crociera.getDataPartenza());
crociera.setnNotti(Integer.parseInt(c.getString(4)));
if (listaPromo.contains(crociera.getCruiseId())) {
crociera.setPromo(true);
Log.v(TAG, "Promo: " + crociera.getCruiseId());
}else {
crociera.setPromo(false);
}
lstCrociere.add(crociera);
}
}
c.deactivate();
c.close();
ListView lvCrociere = (ListView)findViewById(R.id.lvCrociere);
lvCrociere.setAdapter(new ListAdapter(this, R.layout.row_blog, lstCrociere));
lvCrociere.setOnItemClickListener(mItemClickListener);
}
private void ricercaData(String query){
List<Crociera>lstCrociere = new ArrayList<Crociera>();
Cursor c = null;
c = getContentResolver().query(ServiceContentProvider.TABLE13_14_15_16_17_CONTENT_URI, from, "m.name = '" + period + "' AND a.itinerary_desc LIKE '%" + query + "%' GROUP BY a.cruise_id", null, null);
if (c.getCount() > 0) {
while (c.moveToNext()) {
Crociera crociera = new Crociera();
crociera.setCruiseId(c.getString(0));
crociera.setItinerario(c.getString(2));
crociera.setNomeNave(c.getString(8));
String prezzo = c.getString(3).replace(",", ".");
crociera.setPrezzo(Float.parseFloat(prezzo));
crociera.setNomePortoPartenza(c.getString(27));
crociera.setDataPartenza(c.getString(1));
crociera.setArrival_potr_id(c.getString(19));
crociera.setNomePortoArrivo("");
crociera.setDataArrivo("");
crociera.setGiorno(c.getString(1).substring(0,2));
crociera.setMese(crociera.getDataPartenza());
crociera.setnNotti(Integer.parseInt(c.getString(4)));
if (listaPromo.contains(crociera.getCruiseId())) {
crociera.setPromo(true);
Log.v(TAG, "Promo: " + crociera.getCruiseId());
}else {
crociera.setPromo(false);
}
lstCrociere.add(crociera);
}
}
c.deactivate();
c.close();
ListView lvCrociere = (ListView)findViewById(R.id.lvCrociere);
lvCrociere.setAdapter(new ListAdapter(this, R.layout.row_blog, lstCrociere));
lvCrociere.setOnItemClickListener(mItemClickListener);
}
private void ricercaPrezzo(String query){
List<Crociera>lstCrociere = new ArrayList<Crociera>();
Cursor c = null;
c = getContentResolver().query(ServiceContentProvider.TABLE13_14_15_16_17_CONTENT_URI, from, "a.minimum_price = '" + prezzo + "' AND a.itinerary_desc LIKE '%" + query + "%' GROUP BY a.cruise_id", null, null);
if (c.getCount() > 0) {
while (c.moveToNext()) {
Crociera crociera = new Crociera();
crociera.setCruiseId(c.getString(0));
crociera.setItinerario(c.getString(2));
crociera.setNomeNave(c.getString(8));
String prezzo = c.getString(3).replace(",", ".");
crociera.setPrezzo(Float.parseFloat(prezzo));
crociera.setNomePortoPartenza(c.getString(27));
crociera.setDataPartenza(c.getString(1));
crociera.setArrival_potr_id(c.getString(19));
crociera.setNomePortoArrivo("");
crociera.setDataArrivo("");
crociera.setGiorno(c.getString(1).substring(0,2));
crociera.setMese(crociera.getDataPartenza());
crociera.setnNotti(Integer.parseInt(c.getString(4)));
if (listaPromo.contains(crociera.getCruiseId())) {
crociera.setPromo(true);
Log.v(TAG, "Promo: " + crociera.getCruiseId());
}else {
crociera.setPromo(false);
}
lstCrociere.add(crociera);
}
}
c.deactivate();
c.close();
ListView lvCrociere = (ListView)findViewById(R.id.lvCrociere);
lvCrociere.setAdapter(new ListAdapter(this, R.layout.row_blog, lstCrociere));
lvCrociere.setOnItemClickListener(mItemClickListener);
}
private void ricercaPartenza(String query){
List<Crociera>lstCrociere = new ArrayList<Crociera>();
Cursor c = null;
c = getContentResolver().query(ServiceContentProvider.TABLE13_14_15_16_17_CONTENT_URI, from, "p.name = '" + nome + "' AND a.itinerary_desc LIKE '%" + query + "%' GROUP BY a.cruise_id", null, null);
if (c.getCount() > 0) {
while (c.moveToNext()) {
Crociera crociera = new Crociera();
crociera.setCruiseId(c.getString(0));
crociera.setItinerario(c.getString(2));
crociera.setNomeNave(c.getString(8));
String prezzo = c.getString(3).replace(",", ".");
crociera.setPrezzo(Float.parseFloat(prezzo));
crociera.setNomePortoPartenza(c.getString(27));
crociera.setDataPartenza(c.getString(1));
crociera.setArrival_potr_id(c.getString(19));
crociera.setNomePortoArrivo("");
crociera.setDataArrivo("");
crociera.setGiorno(c.getString(1).substring(0,2));
crociera.setMese(crociera.getDataPartenza());
crociera.setnNotti(Integer.parseInt(c.getString(4)));
if (listaPromo.contains(crociera.getCruiseId())) {
crociera.setPromo(true);
Log.v(TAG, "Promo: " + crociera.getCruiseId());
}else {
crociera.setPromo(false);
}
lstCrociere.add(crociera);
}
}
c.deactivate();
c.close();
ListView lvCrociere = (ListView)findViewById(R.id.lvCrociere);
lvCrociere.setAdapter(new ListAdapter(this, R.layout.row_blog, lstCrociere));
lvCrociere.setOnItemClickListener(mItemClickListener);
}
private void ricercaPromo(String query){
List<Crociera>lstCrociere = new ArrayList<Crociera>();
String where = " a.cruise_id IN (SELECT c.cruise_id FROM msc_cabin c LEFT OUTER JOIN msc_promos p ON c.cabin_id = p.cabin_id WHERE c.cabin_id = p.cabin_id GROUP BY c.cruise_id) AND d.name = '" + zona + "' AND a.itinerary_desc LIKE '%" + query + "%' GROUP BY a.cruise_id";
Cursor c = null;
c = getContentResolver().query(ServiceContentProvider.TABLE13_14_15_16_17_CONTENT_URI, from, where, null, null);
if (c.getCount() > 0) {
while (c.moveToNext()) {
Crociera crociera = new Crociera();
crociera.setCruiseId(c.getString(0));
crociera.setItinerario(c.getString(2));
crociera.setNomeNave(c.getString(8));
String prezzo = c.getString(3).replace(",", ".");
crociera.setPrezzo(Float.parseFloat(prezzo));
crociera.setNomePortoPartenza(c.getString(27));
crociera.setDataPartenza(c.getString(1));
crociera.setArrival_potr_id(c.getString(19));
crociera.setNomePortoArrivo("");
crociera.setDataArrivo("");
crociera.setGiorno(c.getString(1).substring(0,2));
crociera.setMese(crociera.getDataPartenza());
crociera.setnNotti(Integer.parseInt(c.getString(4)));
crociera.setPromo(true);
lstCrociere.add(crociera);
}
}
c.deactivate();
c.close();
ListView lvCrociere = (ListView)findViewById(R.id.lvCrociere);
lvCrociere.setAdapter(new ListAdapter(this, R.layout.row_blog, lstCrociere));
lvCrociere.setOnItemClickListener(mItemClickListener);
}
}
答案 0 :(得分:0)
可能是您正在使用为以后的api级别引入的方法...如果有的话,删除所有的lint抑制并检查错误。
编辑:你的活动唯一奇怪的事情就是你在API 11中全局实现了OnQueryTextListener。可能是你在检查版本后应用于searchview的监听器可以解决问题。但这只是猜测。读取logcat告诉我单击listview项后发生错误。也许如果你也可以发布那部分。
我想建议您使用Action Bar Sherlock,它将支持3.0之前的OS上的ActionBar(以及SearchView)
答案 1 :(得分:0)
将您的数据库操作放入AsyncTask。在onPostExecute方法中填充listview。