Android開發帶有圓角列表UI佈局續

MainActivity.java 代碼 實現信息的顯示和隱藏功能
[java] 
public class MainActivity extends Activity { 
    private LinearLayout one; 
    private LinearLayout tow; 
    private LinearLayout three; 
    private LinearLayout four; 
    private static int var1 = 1; 
    private static int var2 = 1; 
    private static int var3 = 1; 
    private static int var4 = 1; 
     
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        setContentView(R.layout.activity_main); 
        one = (LinearLayout) findViewById(R.id.one_mention); 
        tow = (LinearLayout) findViewById(R.id.two_mention); 
        three = (LinearLayout) findViewById(R.id.three_mention); 
        four = (LinearLayout) findViewById(R.id.four_mention); 
         
        findViewById(R.id.oneLayout).setOnClickListener(new OnClickListener() { 
             
            public void onClick(View v) { 
                var1++; 
                if(var1%2 == 0){ 
                    one.setVisibility(View.VISIBLE); 
                }else { 
                    one.setVisibility(View.GONE); 
                } 
            } 
        }); 
         
        findViewById(R.id.twolayout).setOnClickListener(new View.OnClickListener() { 
             
            public void onClick(View v) { 
                var2++; 
                if(var2 % 2 == 0){ 
                    tow.setVisibility(View.VISIBLE); 
                }else { 
                    tow.setVisibility(View.GONE); 
                } 
                 
            } 
        }); 
         
        findViewById(R.id.threelayout).setOnClickListener(new View.OnClickListener() { 
              
            public void onClick(View v) { 
                var3++; 
                if(var3 % 2 == 0){ 
                    three.setVisibility(View.VISIBLE); 
                }else { 
                    three.setVisibility(View.GONE); 
                } 
                 
            } 
        }); 
         
        findViewById(R.id.fourlayout).setOnClickListener(new View.OnClickListener() { 
             
            public void onClick(View v) { 
                var4++; 
                if (var4 % 2 == 0) { 
                    four.setVisibility(View.VISIBLE); 
                }else { 
                    four.setVisibility(View.GONE); 
                } 
            } 
        }); 
         
         
    } 
      

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。