如何减少android活动和应用程序大小? [英] How to reduce android activity and app size?

查看:148
本文介绍了如何减少android活动和应用程序大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是android开发的新手,所以我正在为一种旧语言开发一个字母应用程序,该应用程序看起来像这样

I'm new at android devolpment, so I am developing an alphabet app for an old language, the app would look like this

第一页有一张图片和两个按钮

first page has a picture and two buttons

第一个按钮链接到带有文本的页面

first button links to a page with text

第二个按钮链接到包含24个图像(字母)的页面,如果单击其中一个图像(字母),则转到包含图片(字母)的页面,在图片下方有一个按钮可以收听字母的发音

second button links to a page with 24 images (alphabets), if you click on one of the image (alphabet) then you move on to a page with picture (alphabet) and below the picture there is a button to listen to the pronunciation of the letter

最后,该应用将包含 50 图像 24 音频文件以及至少个30 活动

in the end the app will contain 50 images, 24 audio files and at least 30 activity

并且应用程序尺寸将太大

and the app size will be too large

问题是我可以使用其他东西代替活动吗?还是应该使用使用活动然后减小应用程序尺寸? ProGuard ?

The question is can I use something else instead of activity? or should I use use activity then reduce the app size? ProGuard??

我正在使用android API 21 开发,而最小Api是 API 8

I am developing at android API 21 and the min Api is API 8

推荐答案

您可以将数据传递到Android中的活动和片段中,而无需创建多个具有相似功能的活动.

You can pass data into activities and fragments in Android, there is no need to create multiple activities that have a similar function.

如果您决定使用活动",则可以通过Intent传递数据,其中可以包含其他内容,例如

If you decide to use an Activity you can pass data via an Intent which can contain extras, e.g.

Intent intent = new Intent(this, NextActivity.class);
intent.putExtra("image_id", R.drawable.some_letter);
intent.putExtra("audio_file", "some_letter.mp3");
startActivity(intent);

类似地,您可以将参数的Bundle传递给片段:

Similarly, you can pass a Bundle of arguments to a fragment:

Fragment fragment = new NextFragment();
Bundle args = new Bundle();
args.putInt("image_id", R.drawable.some_letter);
args.putString("audio_file", "some_letter.mp3");
fragment.setArguments(args);
....

这篇关于如何减少android活动和应用程序大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆