这太奇怪了! 当我运行以下活动时,我收到一个错误: “光标在没有事先关闭的情况下完成()”
但我不在这里使用任何光标!!!
public class Categories extends Activity实现OnItemClickListener {
//private AdController myController;
private AdView adView;
private static Context mContext;
TextView tv; Button btn_search;
boolean flag;
// The following are used for the shake detection
private SensorManager mSensorManager;
private Sensor mAccelerometer;
private ShakeDetector mShakeDetector;
//DatabaseConnector databaseConnector=null;
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//--> If API<11 then hide title bar...
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion < android.os.Build.VERSION_CODES.HONEYCOMB){
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
flag=false;
} else //--> only if API >= 11 (honeycomb)
{
//--> Action Bar settings
ActionBar actionBar = getActionBar();
actionBar.setTitle("ΚΑΤΗΓΟΡΙΕΣ");
//actionBar.setSubtitle("by NKdevelopment");
//actionBar.setDisplayHomeAsUpEnabled(true);
flag=true;
//--> Hack to show overflow menu at Action bar even in devices with hard menu button (!!!)
getOverflowMenu();
}
setContentView(R.layout.gridview);
//---> Αυτό εδώ το πρόσθεσα λόγο ενός crash report.. τεστάρουμε και ..βλέπουμε...
//---> Δεν το έχω κάνει upload ακόμα...
WebViewDatabase webViewDB = WebViewDatabase.getInstance(this);
if (webViewDB == null) {
View adView = findViewById(R.id.adView);
if (adView != null)
adView.setVisibility(View.GONE);
}
//---> τέλος ελέγχου crash report..
//---> Disappear up blue button & botton red search button
if(flag) {
tv=(TextView)findViewById(R.id.sort_by);
tv.setVisibility(View.GONE);
btn_search=(Button)findViewById(R.id.btnSearch);
btn_search.setVisibility(View.GONE);
}
mContext=this;
//---> GridView testing
GridView gridview = (GridView) findViewById(R.id.gridview);
gridview.setAdapter(new CustomGridViewAdapter(this));
gridview.setOnItemClickListener(this);
@Override
public void onResume() {
super.onResume();
}
@Override
public void onPause() {
super.onPause();
}
@Override
public void onItemClick(final AdapterView<?> parent, final View item, final int index, final long id)
{
Intent i= new Intent(this, Love_db.class);
Bundle extracase = new Bundle();
switch(index)
{
case 0:
extracase.putString("label", "ΤΗΣ ΑΓΑΠΗΣ");
extracase.putInt("index", index+1);
i.putExtras(extracase);
startActivity(i);
break;
case 1:
extracase.putString("label", "ΑΣΤΕΙΕΣ");
extracase.putInt("index", index+1);
i.putExtras(extracase);
startActivity(i);
break;
}
}
public void onClickSearch(View v) { showDialog(0); }
@Override
protected Dialog onCreateDialog(int id)
{
LayoutInflater inflater=this.getLayoutInflater();
switch(id)
{
case 0:
return new AlertDialog.Builder(this)
.setView(inflater.inflate(R.layout.search_dialog, null))
.setTitle("Αναζήτηση μαντινάδας")
//.setMessage("Αναζητήστε τη μαντινάδα βάση μιας λέξης-κλειδί !")
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
EditText mEdit;
String searchWord;
public void onClick(DialogInterface dialog, int which) {
Dialog f=(Dialog) dialog;
mEdit= (EditText)f.findViewById(R.id.searchWord);
searchWord= mEdit.getText().toString();
System.out.println("searchWord= "+searchWord);
Intent i= new Intent(mContext, Love_db.class);
Bundle extracase = new Bundle();
extracase.putString("label", "ΑΠΟΤΕΛΕΣΜΑΤΑ ΑΝΑΖΗΤΗΣΗΣ");
extracase.putString("searchWord", searchWord);
extracase.putInt("index", 99);
i.putExtras(extracase);
startActivity(i);
}
}
).create();
}
return null;
}
public void onClickAgapimenes(View v) {
Intent ff= new Intent(this, Love_db.class);
Bundle extracase = new Bundle();
extracase.putString("label", "ΟΙ ΑΓΑΠΗΜΕΝΕΣ ΜΟΥ");
extracase.putInt("index", 0);
ff.putExtras(extracase);
startActivity(ff);
}
public void onClickKainourgies(View v) {
Intent nn= new Intent(this, Love_db.class);
Bundle extracase = new Bundle();
extracase.putString("label", "ΚΑΙΝΟΥΡΓΙΕΣ ΜΑΝΤΙΝΑΔΕΣ");
extracase.putInt("index", 98);
nn.putExtras(extracase);
startActivity(nn);
}
private void getOverflowMenu() {
try {
ViewConfiguration config = ViewConfiguration.get(this);
Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
if(menuKeyField != null) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config, false);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onBackPressed() {
AlertDialog.Builder builderExit = new AlertDialog.Builder(this);
builderExit.setMessage("Επιθυμείτε την έξοδο από την εφαρμογή \"Μαντινάδες\";");
builderExit.setPositiveButton("Έξοδος", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
finish();
}
});
builderExit.setNegativeButton("Παραμονή", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
builderExit.create();
builderExit.show();
}
@Override
protected void onStop()
{
if (cc!=null){
cc.close();
}
super.onStop();
} // end of onStop method
@Override
public void onDestroy() {
if (adView != null) {
adView.removeAllViews();
adView.destroy();
}
/*
WebViewDatabase webViewDB = WebViewDatabase.getInstance(this);
if (webViewDB == null) {
View adView = findViewById(R.id.adView);
if (adView != null)
adView.setVisibility(View.GONE);
}
*/
super.onDestroy();
}
}
我在哪里找到Cursor ?????
P.S。我注意到我在第一次运行时只收到一次错误消息...