重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
您好,请参考本段落:
长安网站建设公司创新互联公司,长安网站设计制作,有大型网站制作公司丰富经验。已为长安上千提供企业网站建设服务。企业网站搭建\成都外贸网站建设公司要多少钱,请找那个售后服务好的长安做网站的公司定做!
/**
* 程序入口
*
* @author talentClass
*/
public class MainActivity extends AppCompatActivity implements GameLayout.Game2048Listener {
public static final String SCORE = "score";
/**
* 模式:false为数字,true为图片
*/
private boolean bType;
private TextView tvScore, tvMaxScore; // 当前分数、最高分
private Button btnType, btnRestart; // 设置类型、重新开始
private GameLayout mGameLayout; // 自定义View容器
// 放置图片的数组
private int[] mImages = {R.mipmap.image1, R.mipmap.image2, R.mipmap.image3, R.mipmap.image4, R.mipmap.image5, R.mipmap.image6,
R.mipmap.image7, R.mipmap.image8, R.mipmap.image9, R.mipmap.image10, R.mipmap.image11};
mageView imageview = (ImageView) this.findViewById(R.id.imageview_welcome);
double d1 = 640.00/1136.00;
double d2 = (double)screenWidth/(double)screenHeight;
if(d1d2){
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imageview.getLayoutParams();
params.height = screenHeight;
params.width = (int) (640.00*((double)screenHeight/1136.00));
int m = (int)((double)((double)640.00*((double)screenHeight/1136.00))-screenWidth)/2;
params.leftMargin = -m;
params.rightMargin = -m;
imageview.setLayoutParams(params);
}else if(d2d1){
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imageview.getLayoutParams();
params.width = screenWidth;
params.height = (int) ((double)1136.00*((double)screenWidth/640.00));
int m = (int)((double)((double)1136.00*((double)screenWidth/640.00))-screenHeight)/2;
params.topMargin = -m;
params.bottomMargin = -m;
imageview.setLayoutParams(params);
}
————————————————
用android自带的JSON库,
存档过程
int[] numberArray = {1,3,5,6,9,233,3255};
JSONArraynumbers=new JSONArray();
for(int number : numberArray){
numbers.put(number);
}
String jsonString= numbers.toString();
FileOutputStream fileOut=null;
OutputStreamWriter outStream =null;
try
{
fileOut =new FileOutputStream(saveFilePath,false);
outStream =new OutputStreamWriter(fileOut);
outStream.write(jsonString);
}
catch(Exception e)
{
}
finally
{
try
{
if(null!=outStream)
outStream.close();
if(null!=fileOut)
fileOut.close();
}
catch(Exception e)
{
}
}
读取过程差不多,new 一个FileInputStream 读取其中内容。
然后用这个字符串来初始化JSONArray,就可以得到结果。
记得给应用程序加上读写SD卡的权限。