-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #778 from BingoTrai/master
- Loading branch information
Showing
5 changed files
with
534 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901102/Card.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package edu.hzuapps.androidworks.homeworks.com1314080901102; | ||
|
||
import android.content.Context; | ||
import android.view.Gravity; | ||
import android.view.ViewGroup; | ||
import android.widget.FrameLayout; | ||
import android.widget.TextView; | ||
|
||
/** | ||
* Created by Administrator on 2016/5/11. | ||
*/ | ||
public class Card extends FrameLayout { | ||
|
||
public Card(Context context){ | ||
super(context); | ||
label = new TextView(getContext()); | ||
label.setTextSize(32); | ||
label.setBackgroundColor(0x33ffffff); | ||
label.setGravity(Gravity.CENTER); | ||
|
||
LayoutParams lp = new LayoutParams(-1,-1); | ||
lp.setMargins(10, 10, 0, 0); | ||
addView(label,lp); | ||
|
||
setNum(0); | ||
} | ||
|
||
public int getNum() { | ||
return num; | ||
} | ||
|
||
public void setNum(int num) { | ||
if(num<0){ | ||
label.setText(""); | ||
}else{ | ||
label.setText(num+""); | ||
} | ||
this.num = num; | ||
} | ||
|
||
private int num = 0; | ||
private TextView label; | ||
} |
65 changes: 65 additions & 0 deletions
65
...ava/edu/hzuapps/androidworks/homeworks/com1314080901102/Com1314080901102MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package edu.hzuapps.androidworks.homeworks.com1314080901102; | ||
|
||
import android.content.Intent; | ||
import android.support.v7.app.ActionBarActivity; | ||
import android.os.Bundle; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
|
||
import android.util.Log; | ||
|
||
import edu.hzuapps.androidworks.homeworks.simple_2048.R; | ||
|
||
|
||
public class Com1314080901102MainActivity extends ActionBarActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_com1314080901102_main); | ||
|
||
Button bt1 = (Button) findViewById(R.id.Paly); | ||
Button bt2 = (Button) findViewById(R.id.check); | ||
|
||
bt1.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent intent = new Intent(Com1314080901102MainActivity.this,HomeActivity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
bt2.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
Intent intent = new Intent(Com1314080901102MainActivity.this,ScoreActivity.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
// Inflate the menu; this adds items to the action bar if it is present. | ||
getMenuInflater().inflate(R.menu.menu_com1314080901102_main, menu); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
// Handle action bar item clicks here. The action bar will | ||
// automatically handle clicks on the Home/Up button, so long | ||
// as you specify a parent activity in AndroidManifest.xml. | ||
int id = item.getItemId(); | ||
|
||
//noinspection SimplifiableIfStatement | ||
if (id == R.id.action_settings) { | ||
return true; | ||
} | ||
|
||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
} |
Oops, something went wrong.