Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android開發帶有圓角列表UI布局續

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

編輯:關於Android編程

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); 
                } 
            } 
        }); 
         
         
    } 
      
  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved