android项目实战手机安全卫士_恢复2345安全卫士主界面

android项目实战手机安全卫士_恢复2345安全卫士主界面主界面的布局文件

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

主界面的布局文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/backgroundcolor"
    android:orientation="vertical" >

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="40dip"
        android:background="@drawable/title_background"
        android:gravity="center_horizontal|center_vertical"
        android:orientation="vertical" >
        <TextView 
                    android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#FFF8F8F8"
        android:textSize="22sp"
        android:text="山寨手机卫士"
            />
    </LinearLayout>

    <GridView
        android:id="@+id/gv_main"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="10dip"
        android:horizontalSpacing="10dip"
        android:numColumns="3"
        android:verticalSpacing="10dip" >
    </GridView>

</LinearLayout>

适配器

package cn.itcast.mobilesafe.adapter;

import cn.itcast.mobilesafe.R;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MainUIAdapter extends BaseAdapter {
	private static final String TAG = "MainUIAdapter";
	private Context context;
	private LayoutInflater inflater;
	private static ImageView iv_icon;
	private static TextView tv_name;
	private SharedPreferences sp;
	
	public MainUIAdapter(Context context) {
		this.context = context;
		inflater = LayoutInflater.from(context);
		sp = context.getSharedPreferences("config", Context.MODE_PRIVATE);
	}

	private static String[] names = { "手机防盗", "通讯卫士", "软件管理", "任务管理", "流量管理",
			"手机杀毒", "系统优化", "高级工具", "设置中心" };
	private static int[] icons = { R.drawable.widget05, R.drawable.widget02,
			R.drawable.widget01, R.drawable.widget07, R.drawable.widget05,
			R.drawable.widget04, R.drawable.widget06, R.drawable.widget03,
			R.drawable.widget08 };

	public int getCount() {
		
		return names.length;
	}

	public Object getItem(int position) {
		
		return position;
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// getview的方法被调用了多少次?
		// 9
		// gridview 控件bug 
		// won't fix 
		// 使用静态的变量引用 减少内存中申请的引用的个数 
		
		Log.i(TAG,"getview "+ position);
		View view = inflater.inflate(R.layout.mainscreen_item, null);
		iv_icon =  (ImageView) view.findViewById(R.id.iv_main_icon);
		tv_name =  (TextView) view.findViewById(R.id.tv_main_name);
		iv_icon.setImageResource(icons[position]);
		tv_name.setText(names[position]);
		if(position==0){
			String name = sp.getString("lost_name", null);
			if(name!=null){
				tv_name.setText(name);
			}
		}
		
		return view;
	}

}

mainscreen_item

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="100dip"
    android:layout_height="100dip"
    android:gravity="center_horizontal"
    android:background="@drawable/item_background"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/iv_main_icon"
        android:layout_width="60dip"
        android:layout_height="60dip"
        android:scaleType="fitXY"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/tv_main_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="功能名字"
        android:textColor="@color/textcolor"
        android:textSize="18sp" />

</LinearLayout>

样式文件

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

    <stroke
        android:width="0.5dip"
        android:color="#ff505050" />

    <corners android:radius="2dip" >
    </corners>

	<gradient android:startColor="#ff404040"
	    android:centerColor="#ff383838"
	    android:endColor="#ff404040"
	    />
</shape>

效果

android项目实战手机安全卫士_恢复2345安全卫士主界面

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/190157.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • zigbee开发板(nxpzigbee开发)

    前面我们搭建好了zigbee开发的硬件平台,买一块开发板,注意只要这块开发板上有cc2530,可以向里面烧录程序就可以了。具体的烧录过程我会最近上传我的烧录过程,相关软件我尽快上传。好了回归这一次的主题,那么我们到底需要什么样的开发环境呢?这完全取决于你的项目大小,如果你的项目只是学会使用zigbee,那么你只需要一款烧录软件,以及一款合适的用于编写cc2530的c编译器就OK了。但是我这

    2022年4月10日
    56
  • _bz2 缺少

    _bz2 缺少报错信息from_bz2importBZ2Compressor,BZ2DecompressorModuleNotFoundError:Nomodulenamed’_bz2’解决办法1、安装yuminstallbzip2-devel2、找到_bz2.cpython-37m-x86_64-linux-gnu.so文件如果在机器上没有的话,…

    2022年5月12日
    124
  • 扩展卡尔曼滤波EKF与多传感器融合

    扩展卡尔曼滤波EKF与多传感器融合ExtendedKalmanFilter(扩展卡尔曼滤波)是卡尔曼滤波的非线性版本。在状态转移方程确定的情况下,EKF已经成为了非线性系统状态估计的事实标准。本文将简要介绍EKF,并介绍其在无人驾驶多传感器融合上的应用。

    2022年6月16日
    70
  • Qt学习之QListWidget删除Item

    Qt学习之QListWidget删除Item将QListWidgetItem从QListWidget列表中删除有两种方法可以做到,但也要根据自己的需要进行选择。第一种是QListWidgetItem*takeItem(introw);使用此方法需要知道删除的是第几个Item,并且返回删除的Item指针。第二种是inlinevoidremoveItemWidget(QListWidgetItem*item);需要知道删除

    2022年5月3日
    544
  • Eclipse配置Maven详细教程[通俗易懂]

    Eclipse配置Maven详细教程[通俗易懂]一.使用eclipse自带的maven插件首先,现在下载EclipseMars之后的版本,基本上都自带了maven插件,无需自己再安装maven.有几个注意点:1.默认的本地仓库的目录是在C:\Users\viruser.v-desktop\.m2\repository\如果使用系统默认的maven插件,那么建议还是修改下本地仓库的路径,这样节省C盘空间2.使用的maven版…

    2022年5月25日
    39
  • 阿里云服务器ECS 实例操作(系统选择说明)

    阿里云服务器ECS 实例操作(系统选择说明)

    2021年7月5日
    72

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号