萝卜
来源:互联网 发布:惠州市博罗县网络问政 编辑:程序博客网 时间:2024/05/16 00:35
package com.luobo.www.luoboman;import android.content.Intent;import android.graphics.Color;import android.support.v4.app.FragmentManager;import android.support.v4.app.FragmentTransaction;import android.support.v7.app.AppCompatActivity;import android.os.Bundle;import android.view.View;import android.widget.RadioButton;import android.widget.RadioGroup;import android.widget.Toast;public class MainActivity extends AppCompatActivity implements View.OnClickListener{ FragmentManager fm; FragmentTransaction transaction; Fragment_Home fragment_home; Fragment_class fragment_class; Fragment_cart fragment_cart; Fragment_user fragment_user; RadioGroup radioGroup; RadioButton nav_home,nav_class,nav_cart,nav_mine; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initview(); initdata(); } public void initview(){ fragment_home = new Fragment_Home(); fragment_class = new Fragment_class(); fragment_cart = new Fragment_cart(); fragment_user = new Fragment_user(); nav_home = (RadioButton) findViewById(R.id.nav_home); nav_class = (RadioButton) findViewById(R.id.nav_class); nav_cart = (RadioButton) findViewById(R.id.nav_cart); nav_mine = (RadioButton) findViewById(R.id.nav_mine); radioGroup = (RadioGroup) findViewById(R.id.nav_radioGroup); } public void initdata(){ nav_home.setChecked(true); FragmentManager fm1 = getSupportFragmentManager(); FragmentTransaction ftransaction = fm1.beginTransaction(); ftransaction.replace(R.id.layout,fragment_home); ftransaction.commit(); nav_home.setTextColor(Color.RED); nav_class.setTextColor(Color.BLACK); nav_cart.setTextColor(Color.BLACK); nav_mine.setTextColor(Color.BLACK); radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup radioGroup, int i) { fm = getSupportFragmentManager(); transaction = fm.beginTransaction(); switch (i) { case R.id.nav_home: transaction.replace(R.id.layout,fragment_home); nav_home.setTextColor(Color.RED); nav_class.setTextColor(Color.BLACK); nav_cart.setTextColor(Color.BLACK); nav_mine.setTextColor(Color.BLACK); break; case R.id.nav_class: transaction.replace(R.id.layout,fragment_class); nav_home.setTextColor(Color.BLACK); nav_class.setTextColor(Color.RED); nav_cart.setTextColor(Color.BLACK); nav_mine.setTextColor(Color.BLACK); break; case R.id.nav_cart: transaction.replace(R.id.layout,fragment_cart); nav_home.setTextColor(Color.BLACK); nav_class.setTextColor(Color.BLACK); nav_cart.setTextColor(Color.RED); nav_mine.setTextColor(Color.BLACK); break; case R.id.nav_mine: transaction.replace(R.id.layout,fragment_user); nav_home.setTextColor(Color.BLACK); nav_class.setTextColor(Color.BLACK); nav_cart.setTextColor(Color.BLACK); nav_mine.setTextColor(Color.RED); break; } transaction.commit(); } }); } @Override public void onClick(View view) { switch (view.getId()){ case R.id.nav_top_zxing: Toast.makeText(MainActivity.this,"扫描二维码",Toast.LENGTH_SHORT).show(); Intent intent_zxing = new Intent(MainActivity.this,ZxingActivity.class); startActivity(intent_zxing); break; case R.id.nav_top_talk: Toast.makeText(MainActivity.this,"消息",Toast.LENGTH_SHORT).show(); Intent intent_talk=new Intent(MainActivity.this,TalkActivity.class); startActivity(intent_talk); break; } }}
package com.luobo.www.luoboman;import android.os.Bundle;import android.support.annotation.Nullable;import android.support.v4.app.Fragment;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;/** * Created by 杨文倩 on 2017/10/11. */public class Fragment_cart extends Fragment { @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.item_cart,null); return view; }}
阅读全文
0 0
- 萝卜
- 半个萝卜
- 萝卜花园
- 韩式腌萝卜
- 倔强萝卜
- 拔萝卜
- 素烧白萝卜
- 白萝卜
- 青萝卜
- 红烧萝卜
- 萝卜煲羊排
- Adobe Illustrater绘制萝卜
- 吃不着萝卜的驴子
- 萝卜泡菜在线观看
- 挖个坑,埋个萝卜
- 萝卜炖牛腩
- 邪恶的萝卜
- 一个萝卜三个坑
- Node.js 路由改造
- face_detect_demo()
- Python-位运算符
- YUV视频PSNR计算及代码实现
- angularjs 表格的增删改查
- 萝卜
- java工程师面试题大全-100%公司笔试题你都能碰到几个
- tiny4412新手入门,从零开始一步一步到挂载网络根文件系统
- UVA 10651
- TabLayout横滑菜单+viewpager
- MainActivity
- Effective C++ 20. Prefer pass-by-reference-to-const to pass-by-value
- 51nod 1413 权势二进制 【思维题】
- vue 2.0 数据双向绑定