AndroidStudio微信界面及其功能编写

AndroidStudio微信界面及其功能编写

2023年7月13日发(作者:)

AndroidStudio微信界⾯及其功能编写⼀.外观各部分设计1.底部页⾯ 1.总体horizonal设计

2.内部每个⽅块vertical设计 此处放⼀个例⼦,可以复制四个;

2.头部页⾯ al设计

3.中间页⾯需要囊括头部和尾部页⾯,中间使⽤frame布局 四个切换页⾯1.给出⼀个例⼦ 复制出其他的4个⼆.外观展⽰三.内部各部分代码编写展⽰⼀个模块的代码public class weixin extends Fragment { private static final String ARG_PARAM1 = "param1"; private static final String ARG_PARAM2 = "param2"; private String mParam1; private String mParam2; public weixin() { // Required empty public constructor } public static weixin newInstance(String param1, String param2) { weixin fragment = new weixin(); Bundle args = new Bundle(); ing(ARG_PARAM1, param1); ing(ARG_PARAM2, param2); uments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { te(savedInstanceState); if (getArguments() != null) { mParam1 = getArguments().getString(ARG_PARAM1); mParam2 = getArguments().getString(ARG_PARAM2); } } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return e(nt_weixin, container, false); }} 重点是重写以下⽅法 @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return e(nt_weixin, container, false); }复制出其他四个四.内部代码整合既设计监听器和绑定其他四个界⾯先附上代码public class MainActivity extends AppCompatActivity implements kListener{ private Fragment w=new weixin(); private Fragment s=new settings(); private Fragment c=new contactpeople(); private Fragment f=new friendcircle(); private LinearLayout Lw; private LinearLayout Ls; private LinearLayout Ls; private LinearLayout Lc; private LinearLayout Lf; private ImageButton Bw; private ImageButton Bs; private ImageButton Bc; private ImageButton Bf; private FragmentManager fm; @Override protected void onCreate(Bundle savedInstanceState) { te(savedInstanceState); requestWindowFeature(E_NO_TITLE ); setContentView(ty_main); initView(); initFragment(); initevent(); selectFragment(0); } @Override public void onClick(View view) { switch(()) { case _tab_weixin: case utton1: selectFragment(0); break; case _tab_contactpeople: case utton2: selectFragment(1); break; case _tab_friendcircle: case utton3: selectFragment(2); break; case _tab_settings: case utton4: selectFragment(3); break; default: break; } } private void initFragment(){ fm=getSupportFragmentManager(); FragmentTransaction transaction=ransaction(); (_content,w); (_content,s); (_content,c); (_content,f); (); } private void initView(){ Lw=findViewById(_tab_weixin); Ls=findViewById(_tab_settings); Lc=findViewById(_tab_contactpeople); Lf=findViewById(_tab_friendcircle); Bw=findViewById(utton1); Bs=findViewById(utton2); Bc=findViewById(utton3); Bf=findViewById(utton4); Bf=findViewById(utton4); } private void initevent(){ lickListener(this); lickListener(this); lickListener(this); lickListener(this); } private void hideview(FragmentTransaction transaction){ (w); (s); (c); (f); } private void selectFragment(int i){ FragmentTransaction transaction=ransaction(); hideview(transaction); switch (i){ case 0: (w); //geResource(_weixin_pressed); break; case 1: (s); //geResource(_find_frd_pressed); break; case 2: (c); // geResource(_address_pressed); break; case 3: (f); // geResource(_settings_pressed); break; default: break; } (); }} 以下分为⼏个函数逐⼀解释⾸先是成员变量 private Fragment w=new weixin(); private Fragment s=new settings(); private Fragment c=new contactpeople(); private Fragment f=new friendcircle(); private LinearLayout Lw; private LinearLayout Ls; private LinearLayout Lc; private LinearLayout Lf; private ImageButton Bw; private ImageButton Bs; private ImageButton Bc; private ImageButton Bf; ⾸先是绑定的四个中间界⾯fragment,然后是底部图表的LinearLayout.最后是fragmentmanager然后是三个初始化 private void initFragment(){ fm=getSupportFragmentManager(); FragmentTransaction transaction=ransaction(); (_content,w); (_content,s); (_content,c); (_content,f); (); } private void initView(){ Lw=findViewById(_tab_weixin); Ls=findViewById(_tab_settings); Lc=findViewById(_tab_contactpeople); Lf=findViewById(_tab_friendcircle); Bw=findViewById(utton1); Bs=findViewById(utton2); Bc=findViewById(utton3); Bf=findViewById(utton4); } private void initevent(){ lickListener(this); lickListener(this); lickListener(this); lickListener(this); }分别绑定了对应的view,和设置了监听 private void hideview(FragmentTransaction transaction){ (w); (s); (c); (f); } private void selectFragment(int i){ FragmentTransaction transaction=ransaction(); hideview(transaction); switch (i){ case 0: (w); break; case 1: (s); //geResource(_find_frd_pressed); break; case 2: (c); // geResource(_address_pressed); break; case 3: (f); // geResource(_settings_pressed); break; default: break; } (); }选择fragment的函数(switch语句)点击和创建的重写函数@Override protected void onCreate(Bundle savedInstanceState) { te(savedInstanceState); requestWindowFeature(E_NO_TITLE ); setContentView(ty_main); initView(); initFragment(); initevent(); selectFragment(0); } @Override public void onClick(View view) { switch(()) { case _tab_weixin: case utton1: selectFragment(0); break; case _tab_contactpeople: case utton2: selectFragment(1); break; case _tab_friendcircle: case utton3: selectFragment(2); break; case _tab_settings: case utton4: selectFragment(3); break; default: break; } }在onclick事件内调⽤selectFragment⽅法完成逻辑然后换上⾃⼰想要ifont⽮量图⽂件ps:修正了在bottom中的imagebutton改为imageview不然会出现图⽚⽆法显⽰完全:

发布者:admin,转转请注明出处:http://www.yc00.com/xiaochengxu/1689215939a222266.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信