找传奇、传世资源到传世资源站!

android_换皮肤_Demo源码_

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

换皮肤

android_换皮肤_Demo源码_ Android平台开发-第1张

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));
					}
				});
			}
		});
  }
}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复