2013-07-31 3 views
0

im создание и приложение, которые имеют свои узлы (описание, содержимое, питание), как это изображает http://imgur.com/TmJT6GI, когда пользователь нажимает на любой узел, который он будет расходовать, и покажет в нем еще один экран, как я это сделаю? я увижу, что есть доступный список рассылки, но его единственный список на каждом узле, таком как этот пример, http://ranfeng0610.blog.163.com/blog/static/1857082842011727111359969/ - это расписание listview в каждом узле, в котором я лежал, чтобы расходовать раскладку на узле узла узла, чтобы показать разницу в интерфейсе пользователя.) Как я буду делать это с экрана? помогите мне, пожалуйста, у вас есть какая-нибудь идея ????как создать раскладной макет на каждом узле

  1、main.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="fill_parent" 
> 
<!-- 禁用系统自带图标android:groupIndicator="@null" --> 
<ExpandableListView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:groupIndicator="@null" 
android:id="@+id/mExpandableListView" 
/> 
</LinearLayout> 
2、group.xml 

    <?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation = "horizontal" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<ImageView 
android:layout_width = "25dip" 
android:layout_height = "25dip" 
android:layout_marginTop="10dip" 
android:id="@+id/mImageView" 
/> 
<TextView 
android:id = "@+id/group_tv" 
android:layout_width = "wrap_content" 
android:layout_height = "wrap_content" 
android:paddingLeft = "30px" 
android:paddingBottom = "10px" 
android:textSize = "26sp"/> 
</LinearLayout> 
3、child.xml 

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation = "horizontal" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<ImageView 
android:layout_gravity = "center_vertical" 
android:id = "@+id/child_iv" 
android:layout_width = "70px" 
android:layout_height = "70px" 
android:paddingLeft = "30px" 
android:paddingTop = "2px" 
android:paddingBottom = "5px" 
android:src = "@drawable/icon"/> 
<TextView 
    android:layout_gravity = "center_vertical" 
android:id = "@+id/child_tv" 
android:layout_width = "fill_parent" 
android:layout_height = "fill_parent" 
android:paddingLeft = "30px" 
    android:paddingTop = "10px" 
android:paddingBottom = "5px" 
android:textSize = "30sp"/> 
</LinearLayout> 
+0

u может сделать это без использования расширяемого списка-списка. Нужно просто контролировать видимость ваших просмотров .. но если есть нет представлений, которые вы хотите развернуть, тогда расширяемый список-список предпочтительнее ..! – TheFlash

+0

, но просмотр списка расходных материалов не поддерживает несколько экранов, используется один список для всех узлов. – user2589245

+0

u знаете какой-нибудь пример, который показывает экраны, подобные этому ???? – user2589245

ответ

2

u может сделать это без использования расширяемого списка-списка. Необходимо просто контролировать видимость ваших просмотров.

MainActivity

boolean flag; 
boolean flag2; 
LinearLayout llContains; 
LinearLayout llContents; 
LinearLayout llContains2; 
LinearLayout llContents2; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 


    llContains = (LinearLayout)findViewById(R.id.llContains); 
    llContents = (LinearLayout)findViewById(R.id.llContents); 
    llContains2 = (LinearLayout)findViewById(R.id.llContains2); 
    llContents2 = (LinearLayout)findViewById(R.id.llContents2); 

    llContains.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) 
     { 
      if(!flag) 
      { 
       llContents.setVisibility(View.VISIBLE); 
       flag = true; 
      } 
      else 
      { 
       llContents.setVisibility(View.GONE); 
       flag = false; 
      } 

     } 
    }); 

    llContains2.setOnClickListener(new OnClickListener() { 

     @Override 
     public void onClick(View v) 
     { 
      if(!flag2) 
      { 
       llContents2.setVisibility(View.VISIBLE); 
       flag2 = true; 
      } 
      else 
      { 
       llContents2.setVisibility(View.GONE); 
       flag2 = false; 
      } 

     } 
    }); 


} 

activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    > 

    <ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    > 

<LinearLayout 
    android:id="@+id/llContains" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    > 

    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="3dp" 
    android:background="#000000" 
    > 

    </LinearLayout> 

    <TextView 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:text="Contains" 
     android:textSize="20dp" 
     android:layout_marginLeft="10dp" 
     android:padding="10dp" 
     /> 

    <LinearLayout 
    android:id="@+id/llContents" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:weightSum="4" 
    android:padding="10dp" 
    android:visibility="gone" 
    > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_weight="1" 
     android:gravity="center" 
     > 

    <ImageView 
     android:src="@drawable/ic_launcher" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     /> 

    <TextView 

     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:text="Cheese" 
     /> 

    </LinearLayout> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_weight="1" 
     android:gravity="center" 
     > 

    <ImageView 
     android:src="@drawable/ic_launcher" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_weight="1"/> 

    <TextView 

     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:text="Tomatos" 
     /> 

    </LinearLayout> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_weight="1" 
     android:gravity="center" 
     > 
    <ImageView 
     android:src="@drawable/ic_launcher" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_weight="1"/> 

     <TextView 

     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:text="Wheat" 
     /> 

    </LinearLayout> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_weight="1" 
     android:gravity="center" 
     > 
     <ImageView 
     android:src="@drawable/ic_launcher" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_weight="1"/> 

     <TextView 

     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:text="Salt" 
     /> 

     </LinearLayout> 

</LinearLayout> 



</LinearLayout> 

    <LinearLayout 
    android:id="@+id/llContains2" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    > 

    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="3dp" 
    android:background="#000000" 
    > 

    </LinearLayout> 

    <TextView 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:text="Contains2" 
     android:textSize="20dp" 
     android:layout_marginLeft="10dp" 
     android:padding="10dp" 
     /> 

    <LinearLayout 
     android:id="@+id/llContents2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:weightSum="4" 
     android:padding="10dp" 
     android:visibility="gone" 
     > 

     <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_weight="1" 
     android:gravity="center" 
     > 

    <ImageView 
     android:src="@drawable/ic_launcher" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     /> 

    <TextView 

     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:text="Cheese" 
     /> 

    </LinearLayout> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_weight="1" 
     android:gravity="center" 
     > 

    <ImageView 
     android:src="@drawable/ic_launcher" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_weight="1"/> 

    <TextView 

     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:text="Tomatos" 
     /> 

    </LinearLayout> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_weight="1" 
     android:gravity="center" 
     > 
    <ImageView 
     android:src="@drawable/ic_launcher" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_weight="1"/> 

     <TextView 

     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:text="Wheat" 
     /> 

    </LinearLayout> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:layout_weight="1" 
     android:gravity="center" 
     > 
     <ImageView 
     android:src="@drawable/ic_launcher" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:layout_weight="1"/> 

     <TextView 

     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:text="Salt" 
     /> 

     </LinearLayout> 

     </LinearLayout> 

    </LinearLayout> 

    </LinearLayout> 

    </ScrollView> 
</LinearLayout> 

, если это помогает, то дайте мне знать.

+0

, так как этот макет откроется? когда кнопка click !!!! ????? – user2589245

+0

@ user2589245 запустите мой код и нажмите на contains.and нажмите еще раз на нем. – TheFlash

+0

Метод setOnClickListener (View.OnClickListener) в типе View не применим для аргументов (новый OnClickListener() {}) – user2589245

Смежные вопросы