【发布时间】:2014-07-28 14:03:45
【问题描述】:
我已经为自定义吐司制作了一个基本项目。现在我希望该项目在我未来的项目中作为图书馆工作。如何将我的项目转换为库? P.S:这只是一个虚拟项目,因此我可以学习如何创建自己的库。 代码如下:
public class CustomActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom);
Button btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toast_custom_layout,
(ViewGroup) findViewById(R.id.toast_layout_root));
Toast toast = new Toast(getApplicationContext());
toast.setGravity(Gravity.BOTTOM, 0, 0);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
}
});
}
}
【问题讨论】:
标签: android android-support-library