当前位置:操作系统 > 安卓/Android >>

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); 
                } 
            } 
        }); 
         
         
    } 
      
补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,