• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps startActivity starts blank XML?

kodieh

Lurker
listview.xml
Code:
    <!--?xml version="1.0" encoding="utf-8"?-->
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <ListView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:focusable="false"
            android:id="@+id/lstText">
        </ListView>
    </LinearLayout>
ListView Code
Code:
    package saint.animaltracking;
   
    import android.content.Intent;
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.view.View;
    import android.widget.AdapterView;
    import android.widget.ListView;
   
    import java.util.List;
   
    import saint.animaltracking.helper.AnimalAdapter;
    import saint.animaltracking.helper.DatabaseHelper;
   
    /**
     * Created by Kodie on 3/28/2016.
     */
    public class selectAnimal extends AppCompatActivity
    {
        private ListView lv;
        private List<animal> animal;
        private DatabaseHelper db;
        AnimalAdapter adapter;
        @Override
        protected void onCreate(final Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            db = new DatabaseHelper(this.getApplicationContext());
            setContentView(R.layout.main);
            animal = db.getAllAnimal();
            lv = (ListView) findViewById(R.id.lstText);
   
            adapter = new AnimalAdapter(this, R.layout.list_item, animal);
   
            lv.setAdapter(adapter);
            lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    animal anim = (animal) lv.getItemAtPosition(position);
                    Intent intent = new Intent(getApplicationContext(), specific.class);
                    intent.putExtra("animal", anim);
                    startActivity(intent);
                }
            });
        }
    }
specific.class xml (Generic as I am trying to debug the issue)
Code:
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
   
        <Button
            android:id="@+id/btnButton1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button 1"/>
   
        <Button
            android:id="@+id/btnButton2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button 2"
            android:layout_toRightOf="@+id/btnButton1"/>
   
        <Button
            android:id="@+id/btnButton3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Button 3"
            android:layout_below="@+id/btnButton1"/>
   
        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/btnButton3"
            android:layout_marginTop="94dp"
            android:text="User :"
            android:textAppearance="?android:attr/textAppearanceLarge" />
   
        <EditText
            android:id="@+id/editText1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignTop="@+id/textView1"
            android:layout_toRightOf="@+id/btnButton3" />
   
        <Button
            android:id="@+id/btnSubmit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/editText1"
            android:text="Submit" />
   
    </RelativeLayout>
Specific.java code
Code:
    package saint.animaltracking;
   
    import android.content.Intent;
    import android.database.sqlite.SQLiteOpenHelper;
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.view.View;
    import android.widget.TextView;
   
    /**
     * Created by Kodie on 5/2/2016.
     */
    public class specific extends AppCompatActivity {
        String id;
        private SQLiteOpenHelper AT;
   
        public void onCreate(Bundle savedInstanceState) {
           
            super.onCreate(savedInstanceState);
            setContentView(R.layout.specific);
            Intent intent = getIntent();
        }
    }
The issue I am running into is that when I click the specific listview item to go to the specific animal, all it shows is a blank page. I'm not really sure why though, but I have a strong feeling it has something to do with the way I am writing the OnItemClickListener and OnItemClick or how it is passing the intent to the specific.java class? I've done just about everything I can think of (I've been working in android for about three weeks) to resolve this, outside of trying to rewrite the OnItemClickListener section. Any tips in the right direction are greatly appreciated. Thanks in advance.

UPDATE:
I get the following messages repeatedly when clicking the listitem

> W/ViewRootImpl: Cancelling event due to no window focus: MotionEvent...

> E/Surface: getSlotFromBufferLocked: unknown buffer: 0xb40d53a0
 
If you set a breakpoint at line 21 in specific.java, does it get hit?
 
That's puzzling, you seem to be doing everything right.
I'll have a further think about it..
 
If I point the setContentView to add.xml it will display this xml.

Code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/AddAnimal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:scrollbars="vertical">
    <LinearLayout
        android:layout_width="fill_parent"
        android:orientation="vertical"
        android:layout_height="fill_parent">
    <!--Form controls to follow-->
        <TextView
            android:id="@+id/TextViewTitle"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/formTitle"
            android:textSize = "10pt">
            </TextView>
        <EditText
            android:id="@+id/EditTextMorph"
            android:layout_height="wrap_content"
            android:hint="@string/morph"
            android:inputType="textPersonName"
            android:layout_width="fill_parent">
        </EditText>
        <Spinner
            android:id="@+id/SpinnerSex"
            android:layout_height="wrap_content"
            android:prompt="@string/sex"
            android:layout_width="fill_parent"
            android:entries="@array/genderlist">
        </Spinner>

        <Button
            android:id="@+id/ButtonSendFeedback"
            android:layout_height="169dp"
            android:text="@string/feedbackbutton"
            android:onClick="sendFeedback"
            android:layout_width="385dp">
        </Button>
    </LinearLayout>
</ScrollView>

However, it takes issue with relative layouts and other linear layouts.
 
Even more bizarre! Do you get any issues reported by the UI designer in Android Studio for the layout that doesn't display?
When running the app are there any errors in the log?
 
Back
Top Bottom