当前位置:首页 » 安卓系统 » android统计图

android统计图

发布时间: 2024-04-23 09:07:27

① 做Android 开发怎么选择手机

做Android开发选择手机时,主要从原生性、版本号、屏幕适配三方面考虑。


1. 原生性

原生Android系统是指Google公司发布,没有经过第三方修改的安卓系统。由于Android是开源系统,所以,有的厂商在引入时,会修改其框架层的源码以适应当地的市场或者定制自己的专属功能。显然,经第三方修改过的安卓系统,不再保证原生安卓的普适性,所以在开发时,可能会出现一些未知的BUG。因而,有条件的情况下,建议尽量选择谷歌Nexus系列的手机(设备)进行初期版本的开发测试,以保证最大的兼容性。


2. 版本号

Android版本号是不同时期发布的的Android系统版本编号,对用户而言,它限制了Android的功能特性,对开发者而言,它限制了Android编程接口的种类和数量。由于安卓版本号众多(截止2016年9月,最新的Android正式版本是7.0),各地区的迭代周期不一,导致搭载不同Android版本的设备分布很不均匀,这就是安卓版本的“碎片化”。

不过,Android各版本之间并不是完全独立,而是向后兼容的,也就是说,保证低版本的特性在高版本上也能实现,但是不保证高版本的特性可以在低版本上展示。因而,开发者选择的测试设备搭载的Android版本越低,其开发的应用兼容性就越强。可是实际开发中,不能单一考虑兼容性,还要考虑市场因素。兼容太低版本的设备会极大地限制Android新特性的体现,降低趣味性与互动性,而且还会增加维护成本。

如下图是谷歌对Android版本号的分布统计图(截止到2016年5月),可以看到,低于Android 4.0版本号的设备市场占有率已经少于3%,所以,建议Android开发者在选择手机时最低兼容到4.0就可以了。


最后,在Android开发中,初期的测试建议在Android模拟器上完成,它可以提供比手机等真实设备更广泛的特性定制。在产品逐渐成熟并计划投放到市场时,再参考以上因素,选择有代表性的手机或其它安卓设备进行调试。

② 在Android中要实现图表统计该怎么做

package com.yzxy.draw;

import java.util.ArrayList;
import java.util.HashMap;
import com.yzxy.draw.tools.Tools;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.RectF;
import android.graphics.Paint.Style;
import android.graphics.Typeface;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

@SuppressLint("ViewConstructor")
class MyTuView extends View{

public static final int RECT_SIZE = 10;
private Point mSelectedPoint = null;
public static enum Mstyle
{
Line,scroll
}

private Mstyle mstyle=Mstyle.Line;
private Point[] mPoints = new Point[8];

Context context;
Activity act;
int bheight=0;
Tools tool=new Tools();
HashMap map;
ArrayList dlk;
int totalvalue=30;
int pjvalue=5;
String xstr,ystr;
int margint=15;
int marginb=40;
int c=0;
int resid=0;
Boolean isylineshow;

public MyTuView(Context context,HashMap map,int totalvalue,int pjvalue,String xstr,String ystr,Boolean isylineshow)
{
super(context);
this.context=context;
this.act = (Activity)context;
this.map=map;
this.totalvalue=totalvalue;
this.pjvalue=pjvalue;
this.xstr=xstr;
this.ystr=ystr;
this.isylineshow=isylineshow;
act.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}

@SuppressLint("DrawAllocation")
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// canvas.drawColor(Color.GRAY);
if(c!=0)
this.setbg(c);
if(resid!=0)
this.setBackgroundResource(resid);
dlk=tool.getintfrommap(map);
int height=getHeight();
if(bheight==0)
bheight=height-marginb;

int width=getWidth();

Log.i("w", getWidth()+":"+getHeight());
int blwidh=tool.dip2px(context,50);
int pjsize=totalvalue/pjvalue;

Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(Color.GRAY);
paint.setStrokeWidth(1);
paint.setStyle(Style.STROKE);

// 画直线(横向)
for(int i=0;i xlist=new ArrayList();//记录每个x的值
//画直线(纵向)
for(int i=0;i dlk,HashMap map,ArrayList xlist,int max,int h)
{
Point[] points=new Point[dlk.size()];
for(int i=0;i getMap() {
return map;
}

public void setMap(HashMap map) {
this.map = map;
}

public int getTotalvalue() {
return totalvalue;
}

public void setTotalvalue(int totalvalue) {
this.totalvalue = totalvalue;
}

public int getPjvalue() {
return pjvalue;
}

public void setPjvalue(int pjvalue) {
this.pjvalue = pjvalue;
}

public String getXstr() {
return xstr;
}

public void setXstr(String xstr) {
this.xstr = xstr;
}

public String getYstr() {
return ystr;
}

public void setYstr(String ystr) {
this.ystr = ystr;
}

public int getMargint() {
return margint;
}

public void setMargint(int margint) {
this.margint = margint;
}

public Boolean getIsylineshow() {
return isylineshow;
}

public void setIsylineshow(Boolean isylineshow) {
this.isylineshow = isylineshow;
}

public int getMarginb() {
return marginb;
}

public void setMarginb(int marginb) {
this.marginb = marginb;
}

public Mstyle getMstyle() {
return mstyle;
}

public void setMstyle(Mstyle mstyle) {
this.mstyle = mstyle;
}

public int getBheight() {
return bheight;
}

public void setBheight(int bheight) {
this.bheight = bheight;
}

public int getC() {
return c;
}

public void setC(int c) {
this.c = c;
}

public int getResid() {
return resid;
}

public void setResid(int resid) {
this.resid = resid;
}

}

代码片段
package com.yzxy.draw.tools;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Environment;

public class Tools
{
private final static String ALBUM_PATH = Environment.getExternalStorageDirectory() + "/yueqiu/";

public int dip2px(Context context, float dpValue)
{
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
}

public int px2dip(Context context, float pxValue)
{
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
}

public ArrayList getintfrommap(HashMap map)
{
ArrayList dlk=new ArrayList();
int position=0;
@SuppressWarnings("rawtypes")
Set set= map.entrySet();
@SuppressWarnings("rawtypes")
Iterator iterator = set.iterator();

while(iterator.hasNext())
{
@SuppressWarnings("rawtypes")
Map.Entry mapentry = (Map.Entry)iterator.next();
dlk.add((Double)mapentry.getKey());
}
for(int i=0;i

代码片段
package com.yzxy.draw;

import java.io.IOException;
import java.util.HashMap;

import com.yzxy.draw.MyTuView.Mstyle;
import com.yzxy.draw.tools.Tools;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;

import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.Toast;
import android.app.Activity;
import android.content.res.XmlResourceParser;
import android.graphics.Bitmap;
import android.graphics.Color;

public class MainActivity extends Activity {

MyTuView tu;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

HashMap map=new HashMap();
map.put(1.0, 8.0);
map.put(7.0, 130.0);
map.put(2.0, 4.0);
map.put(3.0, 1.0);
map.put(4.0, 18.0);
map.put(5.0, 160.0);
map.put(6.0, 180.0);
map.put(8.1, 133.5);
tu=new MyTuView(this,map,200,50,"x","y",false);
// tu.setC(Color.CYAN);
tu.setResid(R.drawable.bg);
// tu.setBheight(200);
tu.setTotalvalue(200);

tu.setPjvalue(50);
tu.setXstr("x");
tu.setYstr("y");
tu.setMargint(20);
tu.setBackgroundColor(Color.WHITE);
tu.setMarginb(50);
tu.setMstyle(Mstyle.scroll);
RelativeLayout rela=getlayout(R.layout.activity_main);
rela.addView(tu);
LayoutParams parm=new LayoutParams(1200,400);
parm.setMargins(50, 50, 50, 100);
tu.setLayoutParams(parm);
setContentView(rela);

}

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item)
{
// TODO Auto-generated method stub
if(item.getItemId() == R.id.menu_settings)
{
if (false == tu.isDrawingCacheEnabled())
{
tu.setDrawingCacheEnabled(true);
}
Bitmap bitmap = tu.getDrawingCache();
Tools tool=new Tools();
try {
Boolean b=tool.saveFile(bitmap, "aaaa.png");
if(b)
Toast.makeText(this, "success", Toast.LENGTH_SHORT).show();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(item.getItemId() == R.id.menu_ch)
{
HashMap map=new HashMap();
map.put(1.0, 21.0);
map.put(3.0, 25.0);
map.put(4.0, 32.0);
map.put(5.0, 31.0);
map.put(6.0, 26.0);

tu.setTotalvalue(40);
tu.setPjvalue(10);
tu.setMap(map);
tu.setIsylineshow(true);
tu.postInvalidate();
}
if(item.getItemId() == R.id.menu_ch2)
{
HashMap map=new HashMap();
map.put(1.0, 41.0);
map.put(3.0, 25.0);
map.put(4.0, 32.0);
map.put(5.0, 41.0);
map.put(6.0, 16.0);
map.put(7.0, 36.0);
map.put(8.0, 26.0);
tu.setTotalvalue(50);
tu.setPjvalue(10);
tu.setMap(map);
tu.setMstyle(Mstyle.Line);
tu.setIsylineshow(false);
tu.postInvalidate();
}
return true;
}

public RelativeLayout getlayout(int r)
{
LayoutInflater inflater = (LayoutInflater)getSystemService(android.content.Context.LAYOUT_INFLATER_SERVICE );
try {
XmlResourceParser parser = getResources().getLayout(r);
RelativeLayout layout = (RelativeLayout) inflater.inflate(parser, null);
return layout;
}catch (Exception e) {
// TODO: handle exception
}
return null;
}
}

热点内容
8加6算法 发布:2024-05-18 15:04:25 浏览:737
名图16款尊享什么配置 发布:2024-05-18 14:55:37 浏览:584
我的世界怎样刷出32k服务器 发布:2024-05-18 14:32:32 浏览:565
c语言程序设计江宝钏 发布:2024-05-18 14:32:22 浏览:780
右击文件夹总是转圈圈 发布:2024-05-18 14:31:10 浏览:696
新建数据库phpmyadmin 发布:2024-05-18 14:22:38 浏览:736
安卓手机设备连接在哪里 发布:2024-05-18 14:08:28 浏览:820
路由器的密码最多是多少位 发布:2024-05-18 13:58:18 浏览:420
扫描服务器名称如何填 发布:2024-05-18 13:36:29 浏览:115
芒果缓存的视频看不了视频怎么下载不了 发布:2024-05-18 13:35:14 浏览:520