Android应用程序突然停止

时间:2014-05-12 14:44:50

标签: android layout

我在Android上安装了新的并尝试编写应用程序,但我写了一些代码并在Android设备上运行,直到这里没有任何问题,但是当我尝试启动查询窗口" sorgulama.xml& #34;应用程序像这样停止了我的xml文件

enter image description here

和我的java scource文件(java代码)一样

public class Sorgulama extends Activity implements OnClickListener {

@Override
public void onClick(View v) {
    switch(v.getId())
    {
    case R.id.btnSorgula:
        String sorgu = txtSorgu.getText().toString();
        Sorgula(sorgu);
        break;
    case R.id.btnKisaYollar:
        KisaYollar();
        break;
    case R.id.btnTablo:
        Tablolar();
        break;
    }
}

Button btnSorgula, btnKisaYollar, btnTablo;
EditText txtSorgu;

TableLayout tbl;
ResultSetMetaData metaData;
TableRow renkTableRow;

int kolonSayisi = 0, tvId = 0, otoId = 1;
String url,driver,userName ,password;

ArrayList<String> arrayTablolar = new ArrayList<String>();
ArrayList<String> arrayResults = new ArrayList<String>();

@Override
protected void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.sorgulama);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setTitle("MSSQL Uygulaması v1.0");
Kontroller();
Ayarlar();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE);

}

private void Ayarlar()
{
    DB db = new DB(this);
    db.open();
    Cursor c = db.Query();
    String ipAdresi = null, veriTabaniAdi = null, kullaniciAdi = null, sifre = null;

    while(c.moveToNext())
    {
        ipAdresi = c.getString(c.getColumnIndex("IpAdresi"));
        veriTabaniAdi = c.getString(c.getColumnIndex("VeriTabaniAdi"));
        kullaniciAdi = c.getString(c.getColumnIndex("KullaniciAdi"));
        sifre = c.getString(c.getColumnIndex("Sifre"));
    }

    url = "jdbc:jtds:sqlserver://" + ipAdresi +";databaseName=" +veriTabaniAdi+"";
    driver = "net.sourceforge.jtds.jtbc.Driver";
    userName = kullaniciAdi;
    password = sifre;
    db.close();
}

private void Kontroller()
{
    btnSorgula = (Button) findViewById(R.id.btnSorgula);
    btnKisaYollar = (Button) findViewById(R.id.btnKisaYollar);
    btnTablo = (Button) findViewById(R.id.btnTablo);
    txtSorgu = (EditText) findViewById(R.id.txtSorgu);
    tbl = (TableLayout) findViewById(R.id.tblSonuc);

    btnSorgula.setOnClickListener(this);
    btnKisaYollar.setOnClickListener(this);
    btnTablo.setOnClickListener(this);
}

private void KisaYollar(){
    final CharSequence cs[];
    cs = new String[5];
    cs[0] = "select";
    cs[1] = "*";
    cs[2] = "from";
    cs[3] = "where";
    cs[4] = "and";
    cs[5] = "or";

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Kısa Yollar").setIcon(R.drawable.logo).setItems(cs, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            String sorgu = txtSorgu.getText().toString();
            txtSorgu.setText(sorgu+cs[item]);
        }
    });
    AlertDialog alert = builder.create();
    alert.show();

}

private void Tablolar(){

}

private void Sorgula(String sorgu)
{

}

}

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

你错过了super.onCreate(savedInstanceState)。还

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

必须在setContentView

之前调用