android intents new screen
<p>I am doing an contact list android application but i have a small problem with my screens.
Here is my search.xml code:</p>

<pre><code>  &lt;?xml version="1.0" encoding="utf-8" ?&gt; 
    &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"             android:orientation="vertical" 
 android:layout_width="fill_parent"     
 android:layout_height="fill_parent"&gt;
 &lt;LinearLayout 
 android:orientation="horizontal" 
 android:layout_width="fill_parent" 
  android:layout_height="wrap_content"&gt;
 &lt;EditText android:id="@+id/searchText" 
 android:hint="@string/searchDefault"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content" 
  android:layout_weight="1" /&gt; 
 &lt;Button android:id="@+id/searchButton" 
 android:text="Search" 
 android:layout_width="wrap_content" 
 android:layout_height="wrap_content" /&gt; 
 &lt;/LinearLayout&gt;
  &lt;ListView
 android:id="@android:id/list"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" /&gt;

  &lt;/LinearLayout&gt;
enter code here
</code></pre>

<p>Here is my detalii.xml:</p>

<pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
 &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"&gt;

    &lt;TextView
            android:id="@+id/name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/&gt;
     &lt;ListView
            android:id="@android:id/list"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"/&gt;


    &lt;/LinearLayout&gt;
</code></pre>

<p>My problem is that my screen appears like image from below but i want detalii to appear on entire screen.I dont know what am i doing wrong.Could anybody give me a solution?</p>

<p><img src="http://i.stack.imgur.com/zLP7r.png" alt="enter image description here"></p>

<p>This  is my search.java:</p>

<pre><code>package org.example.dbcontactconsole;




  import android.app.ListActivity;
   import android.content.Intent;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.os.Bundle;
  import android.view.View;
   import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;

  import android.widget.ListView;
  import android.widget.SimpleCursorAdapter;
  import static android.provider.BaseColumns._ID;
    public class Search extends  ListActivity {

 private static int[] TO = {R.id.rowid,R.id.name, R.id.mobilephone, R.id.email };
private static String[] FROM = {_ID,DbConstants.NAME, DbConstants.PHONE, DbConstants.EMAIL, };
private Button sButton;

 private ListView lv1;
 private static SQLiteDatabase db;
  private DbCreate contacts;
  private Cursor cursor;
  private EditText searchText;
  protected SimpleCursorAdapter adapter;


protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search);
    searchText=(EditText)findViewById(R.id.searchText);
    sButton=(Button)findViewById(R.id.searchButton);
    sButton.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            // TODO Auto-generated method stub
            showDatabaseContent();
              lv1 = getListView();

              lv1.setTextFilterEnabled(true);
        }
    });





    }


  private Cursor getContacts() {
      db = contacts.getReadableDatabase();
      cursor = db.rawQuery("SELECT  _id,name, phone, email FROM contactTest1 WHERE name LIKE ?", 
                new String[]{searchText.getText().toString()+"%"});
      startManagingCursor(cursor);
      return cursor;
         }

    public void showDatabaseContent(){
   contacts = new DbCreate(this); 
   try {
       cursor = getContacts(); 
       showContacts(cursor); 
   } finally {
       contacts.close(); 
       db.close();
   }
    }

    private void showContacts(Cursor cursor) {
   //set up data binding
   adapter = new SimpleCursorAdapter(this, R.layout.item, cursor, FROM, TO);
   setListAdapter(adapter);
   }

    public void onListItemClick(ListView parent, View v, int position, long id) {
   Intent abaintent = new Intent(this,Detalii.class);
   Cursor cursor = (Cursor) adapter.getItem(position);
   abaintent.putExtra("Contact_ID", cursor.getInt(cursor.getColumnIndex("_id")));
   startActivity(abaintent);
   }






  }
</code></pre>

<p>Here is my Detalii.java:</p>

<pre><code>package org.example.dbcontactconsole;


      import java.util.ArrayList;
       import java.util.List;

     import android.app.ListActivity;
     import android.content.Intent;
      import android.database.Cursor;
       import android.database.sqlite.SQLiteDatabase;
       import android.net.Uri;
      import android.os.Bundle;
      import android.view.LayoutInflater;
      import android.view.View;
       import android.view.ViewGroup;
      import android.widget.ArrayAdapter;
       import android.widget.ListView;
      import android.widget.TextView;

               public class Detalii extends ListActivity
      { 
      protected TextView contactName;
      protected TextView contactPhone;
      protected TextView email;
      protected int contactId;
      protected  List&lt;Actiune&gt; actiune;
       protected ActiuneAdapter adapter;
      @Override
      public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
   setContentView(R.layout.detalii);

  contactId = getIntent().getIntExtra("Contact_ID",0);
   SQLiteDatabase db = (new DbCreate(this)).getWritableDatabase();
   Cursor cursor = db.rawQuery("SELECT name,phone,email FROM contactTest1 WHERE _id=?",new    String[]{""+contactId});

        if (cursor.getCount() == 1)
      {
    cursor.moveToFirst();

    contactName = (TextView) findViewById(R.id.name);
    contactName.setText(cursor.getString(cursor.getColumnIndex("name")));

   actiune= new ArrayList&lt;Actiune&gt;();
   String phoneString=cursor.getString(cursor.getColumnIndex("phone"));
   if (phoneString!=null)
   {
    actiune.add(new Actiune("Suna la numar",phoneString,Actiune.ACTION_CALL));
    }
   String stringemail = cursor.getString(cursor.getColumnIndex("email"));
   if (stringemail != null) {
           actiune.add(new Actiune("Email", stringemail,Actiune.ACTION_EMAIL));
           }
   adapter = new ActiuneAdapter();
   setListAdapter(adapter);
    }
    }
      public void onListItemClick(ListView parent, View view, int position, long id) {

        Actiune action = actiune.get(position);

       Intent intent;
     switch (action.getType()) {

    case Actiune.ACTION_CALL:  
            Uri callUri = Uri.parse("tel:" + action.getData());  
            intent = new Intent(Intent.ACTION_CALL, callUri);
        startActivity(intent);
            break;

    case Actiune.ACTION_EMAIL:  
    intent = new Intent(Intent.ACTION_SEND);
    intent.setType("plain/text");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[]{action.getData()});
    startActivity(intent);
    break;


       }
     }    

     class ActiuneAdapter extends ArrayAdapter&lt;Actiune&gt; {

     ActiuneAdapter() {
            super(Detalii.this, R.layout.actiune_detalii, actiune);
    }

     @Override
     public View getView(int position, View convertView, ViewGroup parent) {
    Actiune action = actiune.get(position);
    LayoutInflater inflater = getLayoutInflater();
    View view = inflater.inflate(R.layout.actiune_detalii, parent, false);
    TextView label = (TextView) view.findViewById(R.id.label);
    label.setText(action.getLabel());
    TextView data = (TextView) view.findViewById(R.id.data);
    data.setText(action.getData());
    return view;
    }

    }

    }
</code></pre>

<p>Here is my DBconsole.java:</p>

<pre><code>package org.example.dbcontactconsole;

                import android.content.ContentValues;
                import android.content.Intent;
               import android.database.Cursor;
               import android.database.sqlite.SQLiteDatabase;
               import android.os.Bundle;
               import android.view.Menu;
               import android.view.MenuInflater;
               import android.view.MenuItem;
               import android.widget.AdapterView;
               import android.widget.AdapterView.OnItemClickListener;
          import android.widget.AdapterView.OnItemSelectedListener;
          import android.widget.ListView;
           import android.widget.SimpleCursorAdapter;
         import android.widget.Toast;
        import android.view.View;

        import android.app.ListActivity;

        import static android.provider.BaseColumns._ID;

        public class DbContactConsole extends ListActivity {
   private static String[] FROM = {_ID,DbConstants.NAME };
   private DbCreate contacts;
   private static SQLiteDatabase db;
   private static int[] TO = {R.id.rowid,R.id.name,};
   private ListView lv1;
   private static String itemId;
   private Cursor cursor;

   static final int CONTACT_CANCELED = 0;
   static final int CONTACT_ADDED = 1;
   static final int CONTACT_MODIFIED = 2;

   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main); 
      showDatabaseContent();
      lv1 = getListView();

      lv1.setTextFilterEnabled(true);

       lv1.setOnItemClickListener(new OnItemClickListener() {

       public void onItemClick(AdapterView&lt;?&gt; a, View v, int position, long id) { 
           cursor = (Cursor) a.getItemAtPosition(position);
           itemId = cursor.getString(0);
           openOptionsMenu();
           }
       });

             lv1.setOnItemSelectedListener(new OnItemSelectedListener() {

           public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int position, long id){

        }

        public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
            // TODO Auto-generated method stub

        }

       });
   }

   //selected item index from ListView
   public void showDialogItemId(long itemId){
       Toast.makeText(this, "Menu item selected index is" + Long.toString(itemId), Toast.LENGTH_LONG).show();
   }

   @Override
   public boolean onCreateOptionsMenu(Menu menu){
       MenuInflater inflater = getMenuInflater();
       inflater.inflate(R.menu.menu, menu);
       return true;
       }

                  @Override
             public boolean onOptionsItemSelected(MenuItem item){
       switch (item.getItemId()){
           case R.id.modifyitem:
               if(null != itemId){
                   Bundle contactToModify = new Bundle();
                   contactToModify.putString("cFirstName", cursor.getString(1));
                   contactToModify.putString("cMobilePhone", cursor.getString(2));
                   contactToModify.putString("cEmail", cursor.getString(3));
                   contactToModify.putString("mod_type", "modifyPerson");
                   Intent intent = new Intent(this, ContactDetails.class);
                   intent.setClass(this, ContactDetails.class);
                   intent.putExtras(contactToModify);
                   startActivityForResult(intent, CONTACT_MODIFIED);
               }else{
                   Toast.makeText(this, "Select Contact to modify", Toast.LENGTH_LONG).show();
               }
               break;
           case R.id.additem:

               Intent i = new Intent(this, ContactDetails.class);
               Bundle bun = new Bundle();
               bun.putString("mod_type", "addPerson");
               i.setClass(this, ContactDetails.class);
               i.putExtras(bun);
               startActivityForResult(i, CONTACT_ADDED);
               break;

           case R.id.removeitem:
               if(null != itemId){
                   removeContact(itemId);
                   showDatabaseContent();
               }
               else{
                   Toast.makeText(this, "Select Contact to delete", Toast.LENGTH_LONG).show();
               }
               break;
           case R.id.search:
               Intent j =new Intent(this,Search.class);
               j.setClass(this, Search.class);
               startActivity(j);
               break;
       }
       return true;
           }

         @Override
           protected void onActivityResult(int requestCode, int resultCode, Intent intent){
       // See which child activity is calling us back.
       switch (resultCode) {
           case CONTACT_ADDED:
               // This is the standard resultCode that is sent back if the
               // activity crashed or didn't doesn't supply an explicit result.
               if (resultCode == RESULT_FIRST_USER){
                   Bundle bundle = new Bundle();
                   bundle = intent.getBundleExtra("contactData");
                   addContact(bundle);
                   showDatabaseContent();
               } 
               else{
                   Toast.makeText(this, "CANCEL CONTACT BUTTON PRESSED", Toast.LENGTH_LONG).show();
               }
               break;
               case CONTACT_MODIFIED:
               if (resultCode == 2){
                   Bundle bundle = new Bundle();
                   bundle = intent.getBundleExtra("contactData");
                   modifyContact(bundle);
                   showDatabaseContent();
               }
               else{
                   Toast.makeText(this, "MODIFY CONTACT FAILED",    Toast.LENGTH_LONG).show();
               }
               break;
           default:
               break;
       }
   }

 //method removes item from database
   private void removeContact(String itemId){
       db = contacts.getWritableDatabase();
       db.delete(DbConstants.TABLE_NAME, "_ID=" + itemId, null);

        }

             private void addContact(Bundle bundle) {
          // Insert a new record into the Events data source.
          // You would do something similar for delete and update.
          db = contacts.getWritableDatabase();
          ContentValues vals = new ContentValues();
          vals.put(DbConstants.NAME, bundle.getString("contactFirstName"));
          vals.put(DbConstants.PHONE, bundle.getString("contactMobilePhone"));
          vals.put(DbConstants.EMAIL, bundle.getString("contactEmail"));
          db.insertOrThrow(DbConstants.TABLE_NAME, null, vals);
       }

 //method should modify existing Contact
   private void modifyContact(Bundle bundle){
       db = contacts.getWritableDatabase();
       ContentValues vals = new ContentValues();
       vals.put(DbConstants.NAME, bundle.getString("contactFirstName"));
       vals.put(DbConstants.PHONE, bundle.getString("contactMobilePhone"));
       vals.put(DbConstants.EMAIL, bundle.getString("contactEmail"));
       db.update(DbConstants.TABLE_NAME, vals, _ID+"="+itemId, null);
   }

   private Cursor getContacts() {
          db = contacts.getReadableDatabase();
          cursor = db.query(DbConstants.TABLE_NAME, FROM, null, null, null,
                null,DbConstants.NAME);
          startManagingCursor(cursor);
          return cursor;
   }

   public void showDatabaseContent(){
       contacts = new DbCreate(this); 
       try {
           cursor = getContacts(); 
           showContacts(cursor); 
       } finally {
           contacts.close(); 
           db.close();
       }
   }

   private void showContacts(Cursor cursor) {
       //set up data binding
       SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,     R.layout.item, cursor, FROM, TO);
       setListAdapter(adapter);
    }
        }
</code></pre>
