2016-05-21 16 views

答えて

0
l1 = (RelativeLayout) view.findViewById(R.id.layout1); 
    l2 = (RelativeLayout) view.findViewById(R.id.layout2); 
    l3 = (RelativeLayout) view.findViewById(R.id.layout3); 
    l4 = (RelativeLayout) view.findViewById(R.id.layout4); 



    l1.setVisibility(View.GONE); 
    l2.setVisibility(View.GONE); 
    l3.setVisibility(View.GONE); 
    l4.setVisibility(View.GONE); 

    t1.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 


      if (z[0] == 1) { 
       l1.setVisibility(View.GONE); 
       z[0] = 0; 
      } else { 
       l1.setVisibility(View.VISIBLE); 

       z[0] = 1; 
      } 
     } 
    }); 

    t2.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 

      if(z[1]==1){ 
       l2.setVisibility(View.GONE); 
       z[1]=0; 
      } 
      else { 
       l2.setVisibility(View.VISIBLE); 


       z[1]=1; 
      } 

     } 
    }); 
    t3.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 

      if(z[2]==1){ 
       l3.setVisibility(View.GONE); 
       z[2]=0; 
      } 
      else { 

       l3.setVisibility(View.VISIBLE); 


       z[2]=1; 
      } 


     } 
    }); 
    t4.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 

      if(z[3]==1){ 
       l4.setVisibility(View.GONE); 
       z[3]=0; 
      } 
      else { 

       l4.setVisibility(View.VISIBLE); 

       z[3]=1; 
      } 
     } 
    }); 

<RelativeLayout 
      android:id="@+id/layout1" 
      android:layout_width="match_parent" 
      android:layout_marginRight="10dp" 
      android:background="#F9BB5A" 
      android:layout_marginLeft="10dp" 
      android:layout_height="wrap_content" 
      > 

      <EditView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/choose" 
       android:text="Choose one option" 
       android:textColor="#FFFFFF" 
       android:layout_marginLeft="20dp" 
       android:padding="5dp" 
       android:textSize="15sp"/> 

      <Button 
       android:id="@+id/textView2" 
       android:layout_width="140dp" 
       android:layout_height="60dp"/> 



      </RelativeLayout> 

は、同様に多くの相対的なレイアウトを作る行うことができます... は...それはあなたの役に立てば幸い

関連する問題