Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.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
Android 单击时使用片段显示Listview项的说明。Listview项位于活动中,描述位于片段中_Android_Android Layout_Android Fragments - Fatal编程技术网

Android 单击时使用片段显示Listview项的说明。Listview项位于活动中,描述位于片段中

Android 单击时使用片段显示Listview项的说明。Listview项位于活动中,描述位于片段中,android,android-layout,android-fragments,Android,Android Layout,Android Fragments,单击时使用片段显示Listview项的说明。Listview项位于活动中,描述位于片段中 I am trying to implement fragments in my work but failed and posting question after spending about non stop 8 hours. plz help thanks. Here is my Frangment 我试图在我的工作中实现片段,但失败了,在花了大约8个小时不停地发帖。请帮忙,谢谢。 这是我的手稿

单击时使用片段显示Listview项的说明。Listview项位于活动中,描述位于片段中

I am trying to implement fragments in my work but failed and posting question after spending about non stop 8 hours. plz help thanks.
Here is my Frangment
我试图在我的工作中实现片段,但失败了,在花了大约8个小时不停地发帖。请帮忙,谢谢。 这是我的手稿 单击时使用片段显示Listview项的说明。Listview项位于活动中,描述位于片段中

I am trying to implement fragments in my work but failed and posting question after spending about non stop 8 hours. plz help thanks.
Here is my Frangment
我试图在我的工作中实现片段,但失败了,在花了大约8个小时不停地发帖。请帮忙,谢谢。 这是我的手稿 单击时使用片段显示Listview项的说明。Listview项位于活动中,描述位于片段中

I am trying to implement fragments in my work but failed and posting question after spending about non stop 8 hours. plz help thanks.
Here is my Frangment
我试图在我的工作中实现片段,但失败了,在花了大约8个小时不停地发帖。请帮忙,谢谢。 这是我的手稿 单击时使用片段显示Listview项的说明。Listview项位于活动中,描述位于片段中

I am trying to implement fragments in my work but failed and posting question after spending about non stop 8 hours. plz help thanks.
Here is my Frangment
我试图在我的工作中实现片段,但失败了,在花了大约8个小时不停地发帖。请帮忙,谢谢。 这是我的手稿 单击时使用片段显示Listview项的说明。Listview项位于活动中,描述位于片段中

I am trying to implement fragments in my work but failed and posting question after spending about non stop 8 hours. plz help thanks.
Here is my Frangment
我试图在我的工作中实现片段,但失败了,在花了大约8个小时不停地发帖。请帮忙,谢谢。 这是我的手稿 单击时使用片段显示Listview项的说明。Listview项位于活动中,描述位于片段中

I am trying to implement fragments in my work but failed and posting question after spending about non stop 8 hours. plz help thanks.
Here is my Frangment
我试图在我的工作中实现片段,但失败了,在花了大约8个小时不停地发帖。请帮忙,谢谢。 这是我的手稿 单击时使用片段显示Listview项的说明。Listview项位于活动中,描述位于片段中

I am trying to implement fragments in my work but failed and posting question after spending about non stop 8 hours. plz help thanks.
Here is my Frangment
这是片段的布局

    package academic.organizer;

    import android.app.Fragment;
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.TextView;

    public class assignment_description extends Fragment {
    TextView description;
         @Override
            public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
                // Inflate the layout for this fragment
                return inflater.inflate(R.layout.assignment_description, container,    false);


            }

         public void setText(String item) {
             TextView view = (TextView) getView().findViewById(R.id.assignment_description);
             view.setText(item);
           }



    }

试试这个,我还是个新手,所以如果这是错的,我向你道歉

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
   <TextView
        android:id="@+id/assignment_description"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="center_horizontal|center_vertical"
        android:layout_marginTop="20dip"
        android:text="Assignment Description"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textSize="30dip" />

</LinearLayout>



Function for making listview
public void viewAssignments(){

        Log.d("test","test");
        setContentView(R.layout.listview);
        ListView list = (ListView)findViewById(R.id.list);
        ArrayAdapter<String> adapter =new tableCustomList(this, R.layout.lvadapter,assignments);
        list.setAdapter(adapter);
        System.out.println("Registering for context menu");
        registerForContextMenu(list);
    }



//here is what i want to do on listitemclick
@Override
    public void onListItemClick(ListView l, View v, int position, long id) {

        assignment_description fragment =  (assignment_description) getFragmentManager()
                .findFragmentById(R.id.detailFragment);
            if (fragment != null && fragment.isInLayout()) {
              fragment.setText("setting text");}



Here is layout for class containing function viewassignements()
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


 <ListView
     android:id="@+id/list"
     android:layout_width="wrap_content"
     android:layout_height="0px"
     android:layout_gravity="center"
     android:layout_weight="1"
     android:background="@drawable/bg015"
     android:textAlignment="center"
     android:textSize="3dp" />


    <fragment
        android:id="@+id/detailFragment"
        android:layout_width="match_parent"
        android:layout_weight="2"
        android:layout_height="match_parent"
        class="academic.organizer.assignment_description" >
        <!-- Preview: layout=@layout/details -->
    </fragment>

</LinearLayout>




Here are Log Details............./
11-11 02:26:47.727: E/AndroidRuntime(17738): java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
11-11 02:26:47.727: E/AndroidRuntime(17738):    at android.app.ListActivity.onContentChanged(ListActivity.java:243)



**where you can see my layout has a listview with id list.**


jford感谢您的关注,但请收听这里的seetTextString项。。。。我指的是片段布局的文本视图,其中R.id.list位于函数viewsassignment的布局中。这值得一试!您使用作业描述作为类、布局和id?我使用作业描述作为类亲爱的。它不仅仅是类