MYプログラムはエミュレータ上で動作するノートです。Eclipse のコードにエラーはありません。「プロセスが予期せず停止しました」と表示されます。xml コードを自分で実行しようとしましたが、問題なく表示されます。同じアクティビティの db ファイルもありますが、このファイルが問題の原因である可能性が高くなります。答えを見つけるのに役立つものは何も見つかりません。私はプログラミングについてあまり知りませんが、このアプリケーションを研究しています。これに対する解決策は、この問題を抱えているか、この活動に興味を持っている多くの人々を助けるでしょう.
ボタンからデータベースに固定テキストを挿入することに興味があります。
import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
public class Watchnotes extends Activity implements OnClickListener,
android.view.View.OnClickListener {
Button button1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_);
button1.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity, menu);
return true;
}
// public interface
public void onClick(View arg0) {
boolean didItWork = true;
try{
switch (arg0.getId()) {
case R.id.button1:
String note = "XXXX";
NAME entry = new NAMEdb(NAME.this);
entry.open();
entry.createEntry(note);
entry.close();}
}catch (Exception e){
didItWork = false;
}finally{
if (didItWork){
Dialog d = new Dialog(this);
d.setTitle("XXXX");
d.show();}
}
}
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
switch (((View) arg0).getId()){
case R.id.button5:
Intent i = new Intent("com.intent.LIST");
startActivity(i);}}}