自己动手实现android版2048
由于自己写的实验室版2048收到实验室同学热烈欢迎,他们建议我写android版的,所以我就写来给大家娱乐MainActivity.java
package com.game.lab2048;
import java.util.ArrayList;
import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.Menu;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity implements OnGestureListener
{
private static final float FLIP_DISTANCE = 80;
private static final int DIRECTION_UP=0;
private static final int DIRECTION_DOWN=1;
private static final int DIRECTION_LEFT=2;
private static final int DIRECTION_RIGHT=3;
private static final int SIZE=5;
private String username=null;//用户名
private int score=0;//分数
private int highestscore=0;//历史最高分
private TextView tvID=null;//用户名显示
private TextView tvHighest=null;//最高分显示
private TextView tvTime=null;//时间显示
private TextView tvMark=null;//分数显示
private SharedPreferences sp=null;
private Handler mtimer;//定时器
private int begin=0;//时间起点
private Runnable runnable=null;//定时器回调
private int singlewidth=0;
private int singleheight=0;
private float barwidth=0;
private GestureDetector detector=null;
private TextView[][] Pics=new TextView;
private int [][] Data=new int;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
runnable=new Runnable()
{
@Override
public void run()
{
tvTime.setText(begin+"s");
tvMark.setText(score+"");
mtimer.postDelayed(this, 1000);
begin++;
}
};
mtimer=new Handler();
tvID=(TextView)findViewById(R.id.ID);
tvMark=(TextView)findViewById(R.id.mark);
tvTime=(TextView)findViewById(R.id.time);
tvHighest=(TextView)findViewById(R.id.highestscore);
sp=getSharedPreferences("LAB2048",Activity.MODE_PRIVATE);
username=sp.getString("ID","");
tvTime.setText("0");
highestscore=sp.getInt("HighestScore",0);
tvHighest.setText(highestscore+"");
if(username.equals(""))
{
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setIcon(R.drawable.ic_launcher);
builder.setTitle("请输入ID");
final EditText et=new EditText(this);
builder.setView(et);
builder.setPositiveButton("确定", new OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
String input=et.getText().toString();
sp.edit().putString("ID",input).commit();
username=input;
tvID.setText(username);
}
});
builder.show();
}
tvID.setText(username);
tvMark.setText("0");
Pics=(TextView)findViewById(R.id.t00);
Pics=(TextView)findViewById(R.id.t01);
Pics=(TextView)findViewById(R.id.t02);
Pics=(TextView)findViewById(R.id.t03);
Pics=(TextView)findViewById(R.id.t04);
Pics=(TextView)findViewById(R.id.t10);
Pics=(TextView)findViewById(R.id.t11);
Pics=(TextView)findViewById(R.id.t12);
Pics=(TextView)findViewById(R.id.t13);
Pics=(TextView)findViewById(R.id.t14);
Pics=(TextView)findViewById(R.id.t20);
Pics=(TextView)findViewById(R.id.t21);
Pics=(TextView)findViewById(R.id.t22);
Pics=(TextView)findViewById(R.id.t23);
Pics=(TextView)findViewById(R.id.t24);
Pics=(TextView)findViewById(R.id.t30);
Pics=(TextView)findViewById(R.id.t31);
Pics=(TextView)findViewById(R.id.t32);
Pics=(TextView)findViewById(R.id.t33);
Pics=(TextView)findViewById(R.id.t34);
Pics=(TextView)findViewById(R.id.t40);
Pics=(TextView)findViewById(R.id.t41);
Pics=(TextView)findViewById(R.id.t42);
Pics=(TextView)findViewById(R.id.t43);
Pics=(TextView)findViewById(R.id.t44);
LinearLayout ll=(LinearLayout)findViewById(R.id.l00);
singlewidth=ll.getMeasuredWidth();
singleheight=ll.getMeasuredHeight();
barwidth=(float)(singlewidth-Pics.getMeasuredWidth())/2;
detector=new GestureDetector(this);
InitGame();
}
public int RGB(int r,int g,int b)
{
return (0x7f<<24)|((r&0xff)<<16)|((g&0xff)<<8)|(b&0xff);
}
public void AfxMessageBox(String str)
{
Toast.makeText(this, str, Toast.LENGTH_LONG).show();
}
//提交分数->排名继续
public void ShowInfo(int goal)
{
switch(goal)
{
case 0x800:
AfxMessageBox("恭喜,拿下LV1 BOSS");
break;
case 0x1000:
AfxMessageBox("恭喜,拿下LV2 BOSS");
break;
case 0x2000:
AfxMessageBox("恭喜,拿下LV3 BOSS");
break;
case 0x4000:
AfxMessageBox("恭喜,拿下LV4 BOSS");
break;
case 0x8000:
AfxMessageBox("恭喜,拿下LV5 BOSS");
break;
case 0x10000:
AfxMessageBox("恭喜,拿下LV6 BOSS");
break;
}
}
public void InitGame()
{
score=0;
mtimer.removeCallbacks(runnable);
//开启定时器:mtimer.postDelayed(runnable,1000);
begin=0;
for(int i=0;i<SIZE;i++)
{
for(int j=0;j<SIZE;j++)
{
Data=0;
}
}
GetLeftCellsToRandomPlace();
}
public boolean GetLeftCellsToRandomPlace()
{
ArrayList<Integer> left=new ArrayList<Integer>();
for(int i=0;i<SIZE;i++)
{
for(int j=0;j<SIZE;j++)
{
if(Data == 0)
left.add(i*SIZE+j);
}
}
if(left.size() == 0)
return false;
int sel=(int) (Math.random()*left.size());
int ran=(int) (Math.random()*10);
int selx=left.get(sel)/SIZE;
int sely=left.get(sel)%SIZE;
if(ran != 0)
{
Data=2;
}
else
{
Data=4;
}
StartBirthAnimation(selx,sely);
Update();
return true;
}
public Animation StartMoveAnimation(int fromix,int fromiy,int toix,int toiy)
{
float fromXDelta=0.0f,toXDelta=0.0f,fromYDelta=0.0f,toYDelta=0.0f;
fromXDelta=fromix*singlewidth+barwidth;
fromYDelta=fromiy*singleheight+barwidth;
toXDelta=toix*singlewidth+barwidth;
toYDelta=toiy*singleheight+barwidth;
View v=Pics;
Animation anim=new TranslateAnimation(fromXDelta,toXDelta,fromYDelta,toYDelta);
anim.setDuration(200);
v.startAnimation(anim);
return anim;
}
public Animation StartBirthAnimation(int ix,int iy)
{
View v=Pics;
Animation anim=new AlphaAnimation(0,1);
anim.setDuration(200);
v.startAnimation(anim);
return anim;
}
public Animation StartDieAnimation(int ix,int iy)
{
View v=Pics;
Animation anim=new AlphaAnimation(1,0);
anim.setDuration(200);
v.startAnimation(anim);
return anim;
}
public int Get(int x,int y)
{
return Data;
}
public void Set(int x,int y,int val)
{
Data=val;
}
public boolean Combine(int direction)//动画
{
boolean moved=false;
switch(direction)
{
case DIRECTION_LEFT:
{
for(int l=0;l<SIZE;l++)
{
//两两向左合并
int first=0,second;
boolean over=false;
while(first<SIZE && !over)
{
while(first<SIZE-1 && Get(l,first) == 0)
first++;
if(first>=SIZE-1)
{
over=true;
break;
}
second=first+1;
while(second<SIZE && Get(l,second) == 0)
second++;
if(second>=SIZE)
{
over=true;
break;
}
if(Get(l,first) == Get(l,second))
{
Set(l,first,Get(l,first)+Get(l,second));
StartMoveAnimation(l,second,l,first);
ShowInfo(Get(l,first));
Set(l,second,0);
moved=true;
first=second+1;
}
else
{
first=second;
}
}
//全部向左聚集
first=0;
while(first < SIZE && Get(l,first) != 0)
first++;//找到第一个空白处
if(first<SIZE)
{
second=first+1;
while(second<SIZE)
{//找到下一个有值处
while(second<SIZE && Get(l,second) == 0)
{
second++;
}
if(second<SIZE)
{
Set(l,first,Get(l,second));
StartMoveAnimation(l,second,l,first);
Set(l,second,0);
first++;
second++;
moved=true;
}
}
}
}
break;
}
case DIRECTION_RIGHT:
{
for(int l=0;l<SIZE;l++)
{
//两两向右合并
int first=0,second;
boolean over=false;
while(first<SIZE && !over)
{
while(first<SIZE-1 && Get(l,SIZE-1-first) == 0)
first++;
if(first>=SIZE-1)
{
over=true;
break;
}
second=first+1;
while(second<SIZE && Get(l,SIZE-1-second) == 0)
second++;
if(second>=SIZE)
{
over=true;
break;
}
if(Get(l,SIZE-1-first) == Get(l,SIZE-1-second))
{
Set(l,SIZE-1-first,Get(l,SIZE-1-first)+Get(l,SIZE-1-second));
StartMoveAnimation(l,SIZE-1-second,l,SIZE-1-first);
ShowInfo(Get(l,first));
Set(l,SIZE-1-second,0);
moved=true;
first=second+1;
}
else
{
first=second;
}
}
//全部向右聚集
first=0;
while(first < SIZE && Get(l,SIZE-1-first) != 0)
first++;//找到第一个空白处
if(first<SIZE)
{
second=first+1;
while(second<SIZE)
{//找到下一个有值处
while(second<SIZE && Get(l,SIZE-1-second) == 0)
{
second++;
}
if(second<SIZE)
{
Set(l,SIZE-1-first,Get(l,SIZE-1-second));
StartMoveAnimation(l,SIZE-1-second,l,SIZE-1-first);
Set(l,SIZE-1-second,0);
first++;
second++;
moved=true;
}
}
}
}
break;
}
case DIRECTION_UP:
{
for(int c=0;c<SIZE;c++)
{
//两两向上合并
int first=0,second;
boolean over=false;
while(first<SIZE && !over)
{
while(first<SIZE-1 && Get(first,c) == 0)
first++;
if(first>=SIZE-1)
{
over=true;
break;
}
second=first+1;
while(second<SIZE && Get(second,c) == 0)
second++;
if(second>=SIZE)
{
over=true;
break;
}
if(Get(first,c) == Get(second,c))
{
Set(first,c,Get(first,c)+Get(second,c));
StartMoveAnimation(second,c,first,c);
ShowInfo(Get(first,c));
Set(second,c,0);
moved=true;
first=second+1;
}
else
{
first=second;
}
}
//全部向上聚集
first=0;
while(first < SIZE && Get(first,c) != 0)
first++;//找到第一个空白处
if(first<SIZE)
{
second=first+1;
while(second<SIZE)
{//找到下一个有值处
while(second<SIZE && Get(second,c) == 0)
{
second++;
}
if(second<SIZE)
{
Set(first,c,Get(second,c));
StartMoveAnimation(second,c,first,c);
Set(second,c,0);
first++;
second++;
moved=true;
}
}
}
}
break;
}
case DIRECTION_DOWN:
{
for(int c=0;c<SIZE;c++)
{
//两两向右合并
int first=0,second;
boolean over=false;
while(first<SIZE && !over)
{
while(first<SIZE-1 && Get(SIZE-1-first,c) == 0)
first++;
if(first>=SIZE-1)
{
over=true;
break;
}
second=first+1;
while(second<SIZE && Get(SIZE-1-second,c) == 0)
second++;
if(second>=SIZE)
{
over=true;
break;
}
if(Get(SIZE-1-first,c) == Get(SIZE-1-second,c))
{
Set(SIZE-1-first,c,Get(SIZE-1-first,c)+Get(SIZE-1-second,c));
StartMoveAnimation(SIZE-1-second,c,SIZE-1-first,c);
ShowInfo(Get(first,c));
Set(SIZE-1-second,c,0);
moved=true;
first=second+1;
}
else
{
first=second;
}
}
//全部向右聚集
first=0;
while(first < SIZE && Get(SIZE-1-first,c) != 0)
first++;//找到第一个空白处
if(first<SIZE)
{
second=first+1;
while(second<SIZE)
{//找到下一个有值处
while(second<SIZE && Get(SIZE-1-second,c) == 0)
{
second++;
}
if(second<SIZE)
{
Set(SIZE-1-first,c,Get(SIZE-1-second,c));
StartMoveAnimation(SIZE-1-second,c,SIZE-1-first,c);
Set(SIZE-1-second,c,0);
first++;
second++;
moved=true;
}
}
}
}
break;
}
}
return moved;
}
public boolean Judge()
{
int i,j;
for(i=0;i<SIZE;i++)
{
for(j=0;j<SIZE;j++)
{
if(Data == 0)
return true;
if(i+1 < SIZE && Data == Data)
return true;
if(j+1 < SIZE && Data == Data)
return true;
}
}
return false;
}
public int getColor(int val)
{
switch(val)
{
case 0x0:
return RGB(255,255,255);
case 0x2:
return RGB(124,252,0);
case 0x4:
return RGB(102,205,170);
case 0x8:
return RGB(205,92,92);
case 0x10:
return RGB(255,215,0);
case 0x20:
return RGB(255,140,0);
case 0x40:
return RGB(219,112,147);
case 0x80:
return RGB(135,206,215);
case 0x100:
return RGB(0,0,255);
case 0x200:
return RGB(123,104,235);
case 0x400:
return RGB(0,255,0);
case 0x800:
return RGB(255,0,0);
case 0x1000:
return RGB(0,255,255);
case 0x2000:
return RGB(255,0,255);
case 0x4000:
return RGB(255,255,0);
case 0x8000:
return RGB(128,128,128);
case 0x10000:
return RGB(0,0,0);
default:
return RGB(0,0,0);
}
}
//相对于OnPaint
public void Update()
{
for(int i=0;i<SIZE;i++)
{
for(int j=0;j<SIZE;j++)
{
int color=getColor(Data);
Pics.setBackgroundColor(color);
Pics.setTextColor(0xFF000000);
String buffer="";
switch(Data)
{
case 0x0:
break;
case 0x2:
buffer="周志中";
break;
case 0x4:
buffer="庞启雄";
break;
case 0x8:
buffer="刘柳";
break;
case 0x10:
buffer="汪松兴";
break;
case 0x20:
buffer="夏航宇";
break;
case 0x40:
buffer="李妍";
break;
case 0x80:
buffer="徐蕾";
break;
case 0x100:
buffer="李超";
break;
case 0x200:
buffer="吴云";
break;
case 0x400:
buffer="田原";
break;
case 0x800:
buffer="卢老师";
break;
case 0x1000:
buffer="胡老师";
break;
case 0x2000:
buffer="沈老师";
break;
case 0x4000:
buffer="孙院长";
break;
case 0x8000:
buffer="肖国镇";
default:
buffer="神";
break;
}
Pics.setText(buffer);
}
}
}
@Override
public boolean onDown(MotionEvent e)
{
return false;
}
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,float velocityY)
{
int direction=-1;
if(e1.getX() - e2.getX() > FLIP_DISTANCE)
{
direction=DIRECTION_LEFT;
}
else if(e2.getX() - e1.getX() > FLIP_DISTANCE)
{
direction=DIRECTION_RIGHT;
}
if(e1.getY() - e2.getY() > FLIP_DISTANCE)
{
direction=DIRECTION_UP;
}
else if(e2.getY() - e1.getY() > FLIP_DISTANCE)
{
direction=DIRECTION_DOWN;
}
if(direction != -1)
{
if(Combine(direction))
{
GetLeftCellsToRandomPlace();
if(score == 0)
{
mtimer.postDelayed(runnable,1000);
begin=0;
}
score += 100;
if(!Judge())
{
String str1,str2;
if(MeasureScore())
str1="失败!";
else
str1="成功!";
str2="最终得分:"+score;
if(score > highestscore)
{
highestscore=score;
tvHighest.setText(highestscore+"");
sp.edit().putInt("HighestScore",highestscore).commit();
}
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle(str1);
builder.setMessage(str2);
builder.setPositiveButton("上传成绩",new OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
Intent intent=new Intent(MainActivity.this,UploadMark.class);
intent.putExtra("id",username);
intent.putExtra("score",score);
startActivity(intent);
mtimer.removeCallbacks(runnable);
InitGame();
}
});
builder.setNegativeButton("继续游戏",new OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
mtimer.removeCallbacks(runnable);
InitGame();
}
});
builder.show();
}
}
return true;
}
return false;
}
public boolean MeasureScore()
{
int measuredscore=0;
for(int i=0;i<SIZE;i++)
{
for(int j=0;j<SIZE;j++)
{
int val=Get(i,j);
if(val >= 2048)
{
measuredscore += val*100;
}
}
}
score += measuredscore;
if(measuredscore != 0)
return true;
else
return false;
}
@Override
public void onLongPress(MotionEvent e)
{
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,float distanceY)
{
return false;
}
@Override
public void onShowPress(MotionEvent e)
{
}
@Override
public boolean onSingleTapUp(MotionEvent e)
{
return false;
}
@Override
public boolean onTouchEvent(MotionEvent event)
{
return detector.onTouchEvent(event);
}
}
UploadMark.java
package com.game.lab2048;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.util.Xml;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class UploadMark extends Activity
{
private static final String TAG = "UploadMark";
private String id=null;
private String score=null;
private ArrayList<data> da=new ArrayList<data>();
private ListView list=null;
private BaseAdapter adapter=null;
private final class MyAdapter extends BaseAdapter
{
@Override
public int getCount()
{
return da.size();
}
@Override
public long getItemId(int position)
{
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
TextView tv=new TextView(UploadMark.this);
tv.setText(da.get(position).id+":"+da.get(position).score);
return tv;
}
@Override
public Object getItem(int position)
{
// TODO Auto-generated method stub
return null;
}
}
class data
{
private String id;
private String score;
public String getId()
{
return id;
}
public void setId(String id)
{
this.id = id;
}
public String getScore()
{
return score;
}
public void setScore(String score)
{
this.score = score;
}
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.query);
list=(ListView)findViewById(R.id.list);
adapter=new MyAdapter();
list.setAdapter(adapter);
Intent intent=getIntent();
id=intent.getStringExtra("id");
score=intent.getStringExtra("score");
final Handler handler=new Handler()
{
@Override
public void handleMessage(Message msg)
{
adapter.notifyDataSetChanged();
}
};
new Thread()
{
@Override
public void run()
{
try
{
getData(handler);
}
catch (XmlPullParserException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}.start();
}
private void getData(final Handler handler) throws XmlPullParserException
{
String url="http://169.254.132.185:8080/game.jsp?id="+id+"&score="+score;
try
{
URLConnection conn=new URL(url).openConnection();
InputStream instream = conn.getInputStream();
data curdata=null;
XmlPullParser parser=Xml.newPullParser();
parser.setInput(instream,"utf-8");
int type=parser.getEventType();
while(type != XmlPullParser.END_DOCUMENT)
{
if(type == XmlPullParser.START_TAG)
{
String name=parser.getName();
if("item".equals(name))
{
curdata=new data();
}
else if("id".equals(name))
{
curdata.setId(parser.nextText());
}
else if("score".equals(name))
{
curdata.setScore(parser.nextText());
}
}
else if(type == XmlPullParser.END_TAG)
{
String name=parser.getName();
if("item".equals(name))
{
da.add(curdata);
}
}
type=parser.next();
}
instream.close();
if(handler != null)
handler.sendEmptyMessage(0);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/mainll"
android:background="#FFFFFF">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1">
<LinearLayout
android:id="@+id/l00"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t00"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l02"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t02"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l03"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t03"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l04"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t04"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1">
<LinearLayout
android:id="@+id/l10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t10"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l11"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t11"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l12"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t12"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l13"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t13"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l14"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t14"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1">
<LinearLayout
android:id="@+id/l20"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t20"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l21"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t21"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l22"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t22"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l23"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t23"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l24"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t24"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1">
<LinearLayout
android:id="@+id/l30"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t30"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l31"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t31"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l32"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t32"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l33"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t33"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l34"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t34"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1">
<LinearLayout
android:id="@+id/l40"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t40"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l41"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t41"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l42"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t42"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l43"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t43"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
<LinearLayout
android:id="@+id/l44"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="@drawable/outline"
android:padding="5dip"
android:layout_weight="1">
<TextView
android:id="@+id/t44"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text=""
android:background="@null"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal|bottom"
android:text="ID:"/>
<TextView
android:id="@+id/ID"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom|left"
android:text="ID"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_horizontal|bottom"
android:text="最高分:"/>
<TextView
android:id="@+id/highestscore"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="bottom|left"
android:text="最高分"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="耗时:"/>
<TextView
android:id="@+id/time"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|left"
android:text="time"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="分数:"/>
<TextView
android:id="@+id/mark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|left"
android:text="mark"/>
</LinearLayout>
</LinearLayout>
quesy.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/list"/>
</LinearLayout>
安卓版是有官方版的。嘛,还是加油,支持你,做了个山寨的2048。
不过我没测试也没看代码。我想说,如果格子不是4x4的话有点毁这个游戏了。
页:
[1]