Android上使用jspf插件框架的方法
Android上使用jspf插件框架的方法
发布时间:2015-10-28 来源:查字典编辑
摘要:本文实例讲述了Android上使用jspf插件框架的方法。分享给大家供大家参考。具体如下:jspf(JavaSimplePluginFram...

本文实例讲述了Android上使用jspf插件框架的方法。分享给大家供大家参考。具体如下:

jspf (Java Simple Plugin Framework) 是一个插件框架,集成了很多 IoC 框架的概念在里面。

?

package de.jspfdemo;

import net.xeoh.plugins.base.PluginManager;

import net.xeoh.plugins.base.impl.PluginManagerFactory;

import net.xeoh.plugins.base.util.uri.ClassURI;

import android.app.Activity;

import android.os.Bundle;

import android.widget.TextView;

import de.jspfdemo.plugins.CoolPlugin;

import de.jspfdemo.plugins.impl.CoolPluginImpl;

public class JSPFDemo extends Activity {

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(yout.main);

// Loading and adding plugins via class uri

PluginManager pm = PluginManagerFactory.createPluginManager();

pm.addPluginsFrom(new ClassURI(CoolPluginImpl.class).toURI());

// Getting the CoolPlugin

CoolPlugin plugin = pm.getPlugin(CoolPluginImpl.class);

// Setting the text of a TextView with the help of the CoolPlugin

TextView textView = (TextView) findViewById(R.id.textView);

textView.setText(plugin.sayHello());

}

}

希望本文所述对大家的Android程序设计有所帮助。

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新安卓软件开发学习
热门安卓软件开发学习
编程开发子分类