Question

I'm preety new on android and trying to write an application but I wrote some code and run on android device till here there is no any problem but when I try to launch query window "sorgulama.xml" application stopped my xml file like this

enter image description here

and my java scource file ( java code ) like this

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)
{

}

}

Can anyone help me about this issue pls?

Was it helpful?

Solution

you missed super.onCreate(savedInstanceState). Also

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

must be called before setContentView

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top