Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java McClick是否重定向到空白屏幕?_Java_Android_Listview - Fatal编程技术网

Java McClick是否重定向到空白屏幕?

Java McClick是否重定向到空白屏幕?,java,android,listview,Java,Android,Listview,listview.xml <!--?xml version="1.0" encoding="utf-8"?--> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_

listview.xml

<!--?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项转到特定的动物时,它显示的只是一个空白页。我不确定为什么,但我有一种强烈的感觉,这与我编写OnItemClickListener和OnItemClick的方式有关,或者它是如何将意图传递给特定的.java类的?为了解决这个问题,我已经做了我能想到的一切(我已经在android上工作了大约三周),除了试图重写McClickListener部分。任何正确方向的提示都将不胜感激。提前谢谢

更新: 单击listitem时,我反复收到以下消息

W/ViewRootImpl:由于没有窗口焦点而取消事件:MotionEvent

E/Surface:getSlotFromBufferLocked:未知缓冲区:0xb40d53a0


尝试使用spesific类中的随机文本定义一些textview。。或者类似Toast的东西,以证明spesific类是否正在运行。

我强烈感觉这与我编写OnItemClick Listener和OnItemClick的方式有关,或者与它如何将意图传递给特定的.java类有关。。。而是因为你从不在
特定的
class@Selvin我删除了那个代码,因为我不知道这是否是问题所在。我尝试将其作为参数传递给onCreate,并使用getIntent()。尝试注释掉intent.putextra行并运行应用程序。。。我怀疑您是否有意传递对象该问题仍然没有putExtra。我已经用一行日志更新了该问题,我猜这可能是相关的。我删除了XML中的所有内容,并在其上放置了一个大文本视图,表示Toast。它没有出现。请回复我的回复
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);
            }
        });
    }
}
<?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>
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();
    }
}