Results 1 to 2 of 2
  1. #1
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default unable to go to home screen

    Have Happy Day My Seniors!

    My self Raj, i am little familiar with java. But i am new with android os..,


    i am facing an problem while create my android application..,

    i wants to simple

    • insert
    • update
    • delete
    • & search


    details in Database..,

    while i run and insert the records it showing "insert successfully" response message as i set.

    But after that also it staying on the same screen, i have go to app's home option..,


    if normally while we develop a swing application we have to inform after action performed which screen have to display..,

    in this android have to do anything like that..,

    code for InsertActivity..,

    Java Code:
    package com.kancas.search;
    
    import java.io.IOException;
    import android.os.Bundle;
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.content.DialogInterface;
    import android.view.Menu;
    import android.view.View;
    import android.widget.ArrayAdapter;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.Spinner;
    import android.widget.Toast;
    
    public class InsertActivity extends Activity {
    
    	Button insertAll;
    	Button insertOne;
    	
    	DatabaseHandler db;
    	
    	String[] Address = { "Chennai", "Trichy" };
    	String[] Catagory={"Computer","Software","Telecommunication"};
    	
        @Override
        public void onCreate(Bundle savedInstanceState) {
        	
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_insert);
            
            Spinner AddressSpinner = (Spinner) findViewById(R.id.spinner1);
            ArrayAdapter aa = new ArrayAdapter(this,android.R.layout.simple_spinner_item,Address);
            //aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            AddressSpinner.setAdapter(aa);
            
            Spinner CatagorySpunner = (Spinner) findViewById(R.id.spinner2);
         	ArrayAdapter aa2 = new ArrayAdapter(this,android.R.layout.simple_spinner_item,Catagory);
            //aa2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            CatagorySpunner.setAdapter(aa2);
            
            db = new DatabaseHandler(this);
            
            insertAll = (Button) findViewById(R.id.button1);
            insertAll.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                	if(db.checkDataBase()){
                		alertbox("Database", "exiset");
                	}
                	else{
                	    try {
    						db.createDataBase();
    					} catch (IOException e) {
    						// TODO Auto-generated catch block
    						e.printStackTrace();
    					}
                	}
                	db.addData(new Data("John","Chennai","9003574353","x.johnmilton@gmail.com","www.john.com","Computer"));
                	db.addData(new Data("Johnson","Trichy","9791596568","johnson@gmail.com","www.johnson.com","Software"));
                	db.addData(new Data("Yogesh","Chennai","90000000","yogesh@yahoo.com","www.yogesh.com","Telecommunication"));
                	db.addData(new Data("Milton","Trichy","9003574","jaaasas","sadasd","Computer"));
                	db.addData(new Data("aaaa","Chennai","9791596568","x.johnmilton@gmail.com","www.johnson.com","Software"));
                	db.addData(new Data("bbbb","Trichy","9791596568","x.johnmilton@gmail.com","www.johnson.com","Telecommunication"));
                	db.addData(new Data("cccc","Chennai","9791596568","x.johnmilton@gmail.com","www.johnson.com","Computer"));
                	db.addData(new Data("dddd","Trichy","9791596568","x.johnmilton@gmail.com","www.johnson.com","Software"));
                	db.addData(new Data("eeee","Chennai","9791596568","x.johnmilton@gmail.com","www.johnson.com","Telecommunication"));
                	db.addData(new Data("ffff","Trichy","9791596568","x.johnmilton@gmail.com","www.johnson.com","Computer"));
                	db.addData(new Data("gggg","Chennai","9791596568","x.johnmilton@gmail.com","www.johnson.com","Software"));
                	db.addData(new Data("hhhh","Trichy","9791596568","x.johnmilton@gmail.com","www.johnson.com","Telecommunication"));
                }
            });
            
            
            insertOne = (Button) findViewById(R.id.button2);
            insertOne.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                	Data d=new Data();
                	d.setName(((EditText)findViewById(R.id.editText1)).getText().toString());
                	d.setCity(((Spinner)findViewById(R.id.spinner1)).getSelectedItem().toString());
                	d.setPhoneNumber(((EditText)findViewById(R.id.editText3)).getText().toString());
                	d.setEmail(((EditText)findViewById(R.id.editText4)).getText().toString());
                	d.setWeb(((EditText)findViewById(R.id.editText5)).getText().toString());
                	d.setCatagory(((Spinner)findViewById(R.id.spinner2)).getSelectedItem().toString());
                	db.addData(d);
                	Toast.makeText(getApplicationContext(), "Inserted", 3).show();
                	((EditText)findViewById(R.id.editText1)).setText("");
                	//((EditText)findViewById(R.id.editText2)).setText("");
                	((EditText)findViewById(R.id.editText3)).setText("");
                	((EditText)findViewById(R.id.editText4)).setText("");
                	((EditText)findViewById(R.id.editText5)).setText("");
                	
                }
            });
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            getMenuInflater().inflate(R.menu.activity_insert, menu);
            return true;
        }
        
        protected void alertbox(String title, String mymessage)
        {
        new AlertDialog.Builder(this)
           .setMessage(mymessage)
           .setTitle(title)
           .setCancelable(true)
           .setNegativeButton(android.R.string.cancel,
              new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int whichButton){}
              })
           .show();
        }
        
        
        
    }
    i am looking for your help..,
    it will be very help full for develop myself in android..,

    Thanking you..,
    - Raj

  2. #2
    raj.mscking@gmail.com's Avatar
    raj.mscking@gmail.com is offline Senior Member
    Join Date
    Jan 2012
    Location
    TamilNadu
    Posts
    288
    Rep Power
    3

    Default Re: unable to go to home screen

    it is working well thank you..,
    - Raj

Similar Threads

  1. Replies: 9
    Last Post: 09-06-2012, 09:37 AM
  2. login fields on home screen
    By subzero1012 in forum Suggestions & Feedback
    Replies: 0
    Last Post: 03-08-2012, 04:56 AM
  3. Replies: 1
    Last Post: 04-26-2010, 01:02 PM
  4. Make money from home, Home Typing Data Entry Partnerships
    By arturmoniswork in forum Reviews / Advertising
    Replies: 0
    Last Post: 12-30-2008, 05:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •