位置: 编程技术 - 正文
推荐整理分享安卓作业(安卓作业仿银行),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:安卓作业手机银行,安卓作业帮,安卓作业手机银行,安卓作业仿银行,安卓作业手机银行,安卓作业手机银行,安卓作业帮怎么取消自动续费,安卓作业帮怎么取消自动续费,内容如对您有帮助,希望把文章链接给更多的朋友!
FruitAdapter.java
package com.example.ui_listview.adpater;import java.util.List;import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ArrayAdapter;import android.widget.BaseAdapter;import android.widget.ImageView;import android.widget.TextView;import com.example.ui_listview.R;import com.example.ui_listview.model.Fruit;//存在问题:在FruitAdapter的getView()方法中每次都将布局重新加载了一遍,当ListView快速滚动的时候这就会成为性能的瓶颈public class FruitAdapter extends ArrayAdapter<Fruit> {private int resourceId;public FruitAdapter(Context context, int textViewResourceId,List<Fruit> data) {super(context, textViewResourceId, data);resourceId=textViewResourceId;}// 这个方法在每个子项被滚动到屏幕内的时候会被调用@Overridepublic View getView(int position, View convertView, ViewGroup parent) {Fruit fruit = getItem(position);View view=LayoutInflater.from(getContext()).inflate(resourceId, null);ImageView ivFruit=(ImageView) view.findViewById(R.id.ivFruit);TextView tvFruit=(TextView) view.findViewById(R.id.tvFruit);TextView textView=(TextView)view.findViewById(R.id.textView);TextView textView2=(TextView)view.findViewById(R.id.textView2);ivFruit.setImageResource(fruit.getImageId());tvFruit.setText(fruit.getName());textView.setText(fruit.getText());textView2.setText(fruit.getTime());return view;}}
FruitAdapterImprove1.java
package com.example.ui_listview.adpater;import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ArrayAdapter;import android.widget.ImageView;import android.widget.TextView;import com.example.ui_listview.R;import com.example.ui_listview.model.Fruit;//存在问题:虽然现在已经不会再重复去加载布局,但是每次在getView()方法中还是会调用View的findViewById()方法来获取一次控件的实例。public class FruitAdapterImprove1 extends ArrayAdapter {private int resourceId;public FruitAdapterImprove1(Context context, int textViewResourceId) {super(context, textViewResourceId);resourceId = textViewResourceId;}// 这个方法在每个子项被滚动到屏幕内的时候会被调用//getView()方法中还有一个convertView参数,这个参数用于将之前加载好的布局进行缓存,以便之后可以进行重用@Overridepublic View getView(int position, View convertView, ViewGroup parent) {Fruit fruit = (Fruit) getItem(position);View view=null;if(convertView==null) view = LayoutInflater.from(getContext()).inflate(resourceId, null);else view=convertView;ImageView fruitImage = (ImageView) view.findViewById(R.id.ivFruit);TextView fruitName = (TextView) view.findViewById(R.id.tvFruit);fruitImage.setImageResource(fruit.getImageId());fruitName.setText(fruit.getName());return view;}}
FruitAdapterImprove2.java
package com.example.ui_listview.adpater;import android.content.Context;import android.view.LayoutInflater;import android.view.View;import android.view.ViewGroup;import android.widget.ArrayAdapter;import android.widget.ImageView;import android.widget.TextView;import com.example.ui_listview.R;import com.example.ui_listview.model.Fruit;//我们新增了一个内部类ViewHolder,用于对控件的实例进行缓存。//当convertView为空的时候,创建一个ViewHolder对象,并将控件的实例都存放在ViewHolder里,然后调用View的setTag()方法,将ViewHolder对象存储在View中。//当convertView不为空的时候则调用View的getTag()方法,把ViewHolder重新取出。//这样所有控件的实例都缓存在了ViewHolder里,就没有必要每次都通过findViewById()方法来获取控件实例了。public class FruitAdapterImprove2 extends ArrayAdapter {private int resourceId;public FruitAdapterImprove2(Context context, int textViewResourceId) {super(context, textViewResourceId);resourceId = textViewResourceId;}// 这个方法在每个子项被滚动到屏幕内的时候会被调用// getView()方法中还有一个convertView参数,这个参数用于将之前加载好的布局进行缓存,以便之后可以进行重用@Overridepublic View getView(int position, View convertView, ViewGroup parent) {Fruit fruit = (Fruit) getItem(position);View view = null;ViewHolder viewHolder;if (convertView == null) {view = LayoutInflater.from(getContext()).inflate(resourceId, null);viewHolder = new ViewHolder();viewHolder.ivFruit = (ImageView) view.findViewById(R.id.ivFruit);viewHolder.tvFruit = (TextView) view.findViewById(R.id.tvFruit);view.setTag(viewHolder);} else {view = convertView;viewHolder = (ViewHolder) convertView.getTag();}viewHolder.ivFruit.setImageResource(fruit.getImageId());viewHolder.tvFruit.setText(fruit.getName());return view;}class ViewHolder {ImageView ivFruit;TextView tvFruit;}}
Fruit.java
package com.example.ui_listview.model;public class Fruit {private String name;private int imageId;private String text;private String time;public Fruit(String name, int imageId, String text, String time) {super();this.name = name;this.imageId = imageId;this.text = text;this.time = time;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getImageId() {return imageId;}public void setImageId(int imageId) {this.imageId = imageId;}public String getText() {return text;}public void setText(String text) {this.text = text;}public String getTime() {return time;}public void setTime(String time) {this.time = time;}}
fruit_item.xml
<?xml version="1.0" encoding="utf-8"?>< RelativeLayout xmlns:android=" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <ImageView android:id="@id/ivFruit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/p1" /> <TextView android:id="@id/tvFruit" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="dp" android:layout_marginLeft="dp" android:layout_toRightOf="@id/ivFruit" android:text="Apple" /> <TextView android:id="@id/textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignLeft="@id/tvFruit" android:layout_below="@id/tvFruit" android:layout_marginLeft="dp" android:text="今天真高兴" /> <TextView android:id="@id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@id/tvFruit" android:layout_alignBottom="@id/tvFruit" android:layout_alignParentRight="true" android:layout_marginRight="dp" android:text="TextView" />< /RelativeLayout>
activity_main.xml
<LinearLayout xmlns:android=" xmlns:tools=" android:id="@id/LinearLayout1" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" > <ListView android:id="@id/lvFruits" android:layout_width="match_parent" android:layout_height="wrap_content" > </ListView>< /LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>< manifest xmlns:android=" package="com.example.ui_listview" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/myTheme" > <activity android:name="com.example.ui_listview.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application>< /manifest>
程序员应该学习的签名破解 我们以XXXX管家为例,该apk使用了签名保护。我们对apk二次打包后,程序无法运行。原因是程序运行时会获取当前应用签名和官方签名进行对比。如果发
菜鸟学安卓Log.v("第一篇")——为何突然想写安卓学习的博客? CSDN的博客从大一下学期就有了,可是到现在还没有发挥它的作用,理由却是充足的,因为那个时候自己还是一个在不断探索的菜鸟,还在思考是学c好还
Android的性能监控工具StrictMode 目前,StrictMode的能力与限制包括:1.基于线程的对磁盘读写,网络操作,以及自定义耗时操作等的监控;2.基于VM进程的对对象泄露(Activity对象,SQLite
标签: 安卓作业仿银行
本文链接地址:https://www.jiuchutong.com/biancheng/374580.html 转载请保留说明!友情链接: 武汉网站建设