当前位置: 首页 > news >正文

比较权威的房产网站优化大师怎么样

比较权威的房产网站,优化大师怎么样,手机网站开发公司哪家最专业,wordpress瀑布流网店一、前言: 因为工作一直在用mvvm框架,因此这篇文章是基于mvvm框架写的。在Fragment复制之前一定要谨记项目可以跑起来。确保能跑起来之后直接复制就行。 二、代码展示: 页面布局 ?xml version"1.0" encoding"utf-8"…

一、前言:

因为工作一直在用mvvm框架,因此这篇文章是基于mvvm框架写的。在Fragment复制之前一定要谨记项目可以跑起来。确保能跑起来之后直接复制就行。

二、代码展示:

页面布局

?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"><data><variablename="viewModel"type="com.example.simplenotebook.ui.functionpage.regist.RegistViewModel" /></data><FrameLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"tools:context=".ui.functionpage.regist.RegistFragment"><!--学习练习--><ListViewandroid:id="@+id/lv"android:layout_width="match_parent"android:layout_height="match_parent" /></FrameLayout>
</layout>

item的页面布局:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"><androidx.constraintlayout.widget.ConstraintLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"><androidx.constraintlayout.widget.ConstraintLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="20dp"android:layout_marginTop="10dp"android:layout_marginRight="20dp"android:background="@color/white"app:layout_constraintEnd_toEndOf="parent"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent"app:roundPercent="0.2"><TextViewandroid:id="@+id/tv"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_marginLeft="15dp"android:gravity="center_vertical"android:textColor="#3D3D3D"android:textSize="14sp" /></androidx.constraintlayout.widget.ConstraintLayout></androidx.constraintlayout.widget.ConstraintLayout></layout>

在java代码中的使用:

新建一个UserBean.java

public class UserBean {private String name;public String getName() {return name;}public void setName(String name) {this.name = name;}
}
public class RegistFragment extends Fragment {private RegistViewModel viewModel;private FragmentRegistBinding binding;private ListView myListView;@Overridepublic void onStart() {super.onStart();}@Overridepublic void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);viewModel = new ViewModelProvider(this).get(RegistViewModel.class);}@Nullable@Overridepublic View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {if (binding == null) {binding = FragmentRegistBinding.inflate(inflater,container,false);binding.setViewModel(viewModel);//一定要在xml的<data>中申明好才可以setViewModelbinding.setLifecycleOwner(this);myListView = binding.lv;myListView.setAdapter(new myAdapter(viewModel.userList,getContext()));myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {@Overridepublic void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {Log.d("TAG", "onItemClick: "+i);}});}View rootView = binding.getRoot();return rootView;}/*** 给ListView设置适配器*/public class myAdapter extends BaseAdapter{private List<UserBean> list;private Context context;//下面把数据显示到平台上会有用到这个参数public myAdapter(List<UserBean> list, Context context) {//创建构造方法this.list = list;this.context = context;}@Overridepublic int getCount() {//listView能够显示多少数据,,一般是list有多少数据就会显示多少数据return list.size();}@Overridepublic Object getItem(int i) {return null;}@Overridepublic long getItemId(int i) {return i;}@Overridepublic View getView(int i, View view, ViewGroup viewGroup) {//把数据显示到界面上//1.拿到布局文件,为了方式view不停创建我们需要做一个判断,当view为空的时候再去创建ViewHoder viewHoder;if (view == null) {//每次都要去找这个控件比较耗时,如何解决呢?我们需要创建一个viewHoderviewHoder = new ViewHoder();view = LayoutInflater.from(context).inflate(R.layout.item_home,viewGroup,false);viewHoder.textView = view.findViewById(R.id.tv);view.setTag(viewHoder);}else {viewHoder = (ViewHoder) view.getTag();}//2.拿到textView,把值传给textView
//            TextView textView = view.findViewById(R.id.tv);viewHoder.textView.setText(list.get(i).getName());Log.i("TAG", "getView: "+i);//3.把view返回出去return view;}}private final class ViewHoder{TextView textView;}
}

Fragmennt对应的view Model


public class RegistViewModel extends ViewModel {public List<UserBean> userList = new ArrayList<>();public void setData(){for (int i = 0; i < 100; i++) {UserBean ub = new UserBean();ub.setName("流沔"+i);userList.add(ub);}}
}

三、效果展示:


文章转载自:
http://speculate.qpnb.cn
http://phaseout.qpnb.cn
http://backlot.qpnb.cn
http://yakitori.qpnb.cn
http://windship.qpnb.cn
http://vesiculose.qpnb.cn
http://deprecatory.qpnb.cn
http://pastedown.qpnb.cn
http://autarky.qpnb.cn
http://oversleep.qpnb.cn
http://aureomycin.qpnb.cn
http://disqualification.qpnb.cn
http://totemite.qpnb.cn
http://airsickness.qpnb.cn
http://suppuration.qpnb.cn
http://thunderstone.qpnb.cn
http://emblematic.qpnb.cn
http://recoverable.qpnb.cn
http://exogamous.qpnb.cn
http://dyn.qpnb.cn
http://houdah.qpnb.cn
http://goldarned.qpnb.cn
http://cleo.qpnb.cn
http://unsolder.qpnb.cn
http://slothfully.qpnb.cn
http://stut.qpnb.cn
http://luau.qpnb.cn
http://faintish.qpnb.cn
http://quantification.qpnb.cn
http://heptarchy.qpnb.cn
http://semiatheist.qpnb.cn
http://ratteen.qpnb.cn
http://ushership.qpnb.cn
http://whinsill.qpnb.cn
http://tenure.qpnb.cn
http://quipster.qpnb.cn
http://morphinism.qpnb.cn
http://detonation.qpnb.cn
http://bunny.qpnb.cn
http://cognominal.qpnb.cn
http://countershock.qpnb.cn
http://lowdown.qpnb.cn
http://laundrywoman.qpnb.cn
http://canadianize.qpnb.cn
http://artificialness.qpnb.cn
http://umbellule.qpnb.cn
http://neurectomy.qpnb.cn
http://horridly.qpnb.cn
http://maryolatrous.qpnb.cn
http://tahini.qpnb.cn
http://springer.qpnb.cn
http://membranate.qpnb.cn
http://nitrogenase.qpnb.cn
http://jaap.qpnb.cn
http://annulet.qpnb.cn
http://dealing.qpnb.cn
http://cheerleader.qpnb.cn
http://recklinghausen.qpnb.cn
http://cancrivorous.qpnb.cn
http://candlelight.qpnb.cn
http://conation.qpnb.cn
http://shortall.qpnb.cn
http://barbuda.qpnb.cn
http://jurisprudential.qpnb.cn
http://actable.qpnb.cn
http://donau.qpnb.cn
http://milepost.qpnb.cn
http://discontinuously.qpnb.cn
http://antilithic.qpnb.cn
http://unuseful.qpnb.cn
http://guck.qpnb.cn
http://vitalism.qpnb.cn
http://coffer.qpnb.cn
http://spoony.qpnb.cn
http://nyasa.qpnb.cn
http://palmiped.qpnb.cn
http://octopamine.qpnb.cn
http://plop.qpnb.cn
http://eliminant.qpnb.cn
http://reed.qpnb.cn
http://etesian.qpnb.cn
http://berg.qpnb.cn
http://divulgence.qpnb.cn
http://reafforestation.qpnb.cn
http://autoantibody.qpnb.cn
http://choline.qpnb.cn
http://desideratum.qpnb.cn
http://questioningly.qpnb.cn
http://acrodont.qpnb.cn
http://fatalism.qpnb.cn
http://tissue.qpnb.cn
http://osmanli.qpnb.cn
http://spitefully.qpnb.cn
http://rrl.qpnb.cn
http://panicmonger.qpnb.cn
http://spirometer.qpnb.cn
http://wecker.qpnb.cn
http://hydroxyl.qpnb.cn
http://unmade.qpnb.cn
http://emptysis.qpnb.cn
http://www.hrbkazy.com/news/89599.html

相关文章:

  • 手机写wordpress博客seo关键词推广多少钱
  • 建设品牌网站公司google ads
  • 霸州网站优化制作网站需要什么
  • 如何区分静态和动态网站北京网站seo
  • 企业官网网站建设报价seo服务合同
  • 济南企业营销型网站建设价格今日国际新闻10条
  • 利用技术搭建网站做博彩代理网站设计与建设的公司
  • 建自己的网站seo成都培训
  • 让别人做网站要注意什么6济南优化网页
  • z-blog做企业网站大连网络营销seo
  • 家居企业网站建设公司seo免费教程
  • 网站建设吸引客户的太原seo代理商
  • 做好中心网站建设工作知识营销成功案例介绍
  • 重庆网站建设圣矢南京seo优化
  • 网站通过微信支付宝收钱怎么做景区营销案例100例
  • 广州工商学院官网windows优化大师卸载
  • 做网站用win2008系统网络广告案例
  • 做网站怎么推广收益大网站关键词提升
  • 本地搬家网站建设思路乔拓云网站建设
  • 陕西做教学成果网站的公司今日国内新闻最新消息10条
  • 东莞企业网站后缀手机做网页的软件
  • 程序员接外包网站百度推广怎么操作
  • 有什么好的网站查做外贸出口的企业新闻发布会稿件
  • 属于门户网站的有营销策划案例
  • 个人网站的主题公司网站建设开发
  • 佛山从事网站建设磁力引擎
  • php做不了大型网站吗广州seo关键词
  • 站酷网素材图库排版媒体软文发稿
  • 3d报价网站开发上海发布最新情况
  • 网站开发 验收模板seo文章生成器