【问题标题】:Converting project as a library [duplicate]将项目转换为库[重复]
【发布时间】: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


【解决方案1】:

您在使用 Eclipse 吗?然后, 项目右键->属性->Android->勾选Is Library(放在下方)

如果您使用的是安卓工作室, 在您的 build.gradle 文件中,使用 apply plugin: 'com.android.library' notapply plugin: 'com.android.application'

【讨论】:

    【解决方案2】:

    如果您使用的是 Eclipse

    右击Project --> Properties --> Android并勾选Is Library复选框

    【讨论】:

    • 我知道这部分。我什至在创建项目时将其作为库项目进行了检查。但这个项目行不通。在你的系统上试试这个,告诉我是否需要改变。有一些错误。
    • @Apoorv 清理你的项目。
    • 你在说什么项目?
    • @Apoorv 请尝试上面的代码并告诉我缺少什么。
    • 我看到的只是布局文件,因为我没有创建它
    猜你喜欢
    • 2013-04-08
    • 1970-01-01
    • 1970-01-01
    • 2012-01-21
    • 1970-01-01
    • 2016-07-14
    • 2021-04-24
    • 2023-03-15
    • 1970-01-01
    相关资源
    最近更新 更多