基本信息
源码名称:android 换皮肤 Demo源码
源码大小:0.39M
文件格式:.zip
开发语言:Java
更新时间:2016-03-09
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

换皮肤

package com.kris.reskin;

import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

public class Re_SkinActivity extends Activity {
	private LinearLayout layout;
	private Button btnSet;
	private Context friendContext;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        btnSet = (Button)findViewById(R.id.button1);
        layout = (LinearLayout)findViewById(R.id.layout);
        layout.setBackgroundResource(R.drawable.bg);
        //com.kris.reskin1
        try {
			friendContext =  createPackageContext("com.kris.reskin1", Context.CONTEXT_IGNORE_SECURITY);
		} catch (NameNotFoundException e) {
			e.printStackTrace();
		}
        btnSet.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				new Handler().post(new Runnable() {
					@Override
					public void run() {
						layout.setBackgroundDrawable(friendContext.getResources().getDrawable(R.drawable.bg));
					}
				});
			}
		});
    }
}