forked from hzuapps/android-labs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,228 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901214/About.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,14 @@ | ||
package com.example.dictionary; | ||
|
||
import android.app.Activity; | ||
import android.os.Bundle; | ||
import android.widget.TextView; | ||
|
||
public class About extends Activity { | ||
private TextView text; | ||
protected void onCreate(Bundle savedInstanceState){ | ||
super.onCreate(savedInstanceState); | ||
this.setContentView(R.layout.about); | ||
text = (TextView) findViewById(R.id.text); | ||
} | ||
} |
114 changes: 114 additions & 0 deletions
114
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901214/EditWord.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,114 @@ | ||
package com.example.dictionary; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.text.TextUtils; | ||
import android.view.View; | ||
import android.view.View.OnClickListener; | ||
import android.view.Window; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.SimpleAdapter; | ||
import android.widget.Toast; | ||
|
||
public class EditWord extends Activity implements OnClickListener { | ||
private String action; | ||
private EditText zhushi; | ||
private EditText meanning; | ||
private Button confirm; | ||
private Button cancel; | ||
int index = -1; | ||
private Bundle bundle; | ||
private ArrayList<HashMap<String, String>> arrayList; | ||
|
||
@SuppressWarnings("unchecked") | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
// 设置隐藏标题 | ||
requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
setContentView(R.layout.edit); | ||
Bundle bundle = this.getIntent().getExtras(); | ||
action = bundle.getString("action"); | ||
|
||
initWidgets(); | ||
} | ||
|
||
private void initWidgets() { | ||
// spelling是单词,meanning是解释,confirm是确定,cancel是取消 | ||
zhushi = (EditText) findViewById(R.id.zhushi); | ||
meanning = (EditText) findViewById(R.id.meanning); | ||
confirm = (Button) findViewById(R.id.button1); | ||
cancel = (Button) findViewById(R.id.button2); | ||
cancel.setOnClickListener(this); | ||
confirm.setOnClickListener(this); | ||
|
||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
// TODO Auto-generated method stub | ||
super.onResume(); | ||
if (action.equals("edit")) { | ||
zhushi.setText(bundle.getString("word")); | ||
meanning.setText(bundle.getString("explain")); | ||
index = bundle.getInt("index"); | ||
} | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public void onClick(View v) { | ||
// TODO Auto-generated method stub | ||
|
||
String word = meanning.getText().toString().trim(); | ||
String explain = zhushi.getText().toString().trim(); | ||
if (v == cancel) { | ||
finish(); | ||
} | ||
if (v == confirm) { | ||
if (meanning.getText().toString().equals("") | ||
|| zhushi.getText().toString().equals("")) { | ||
Toast.makeText(EditWord.this, "信息不能为空", Toast.LENGTH_SHORT) | ||
.show(); | ||
} | ||
|
||
else { | ||
Intent intent = getIntent(); | ||
arrayList = (ArrayList<HashMap<String, String>>) new ObjectFile() | ||
.readObjectFile(); | ||
if (null == arrayList) { | ||
arrayList = new ArrayList<HashMap<String, String>>(); | ||
} | ||
if (!TextUtils.isEmpty(word) && !TextUtils.isEmpty(explain)) { | ||
if (index == -1) { | ||
HashMap<String, String> map = new HashMap<String, String>(); | ||
map.put("word", word); | ||
map.put("explain", explain); | ||
arrayList.add(map); | ||
|
||
}else{ | ||
HashMap<String, String> map = new HashMap<String, String>(); | ||
map.put("word", word); | ||
map.put("explain", explain); | ||
arrayList.set(index, map); | ||
} | ||
new ObjectFile().writeObjectFile(arrayList); | ||
} | ||
|
||
SimpleAdapter adapter = new SimpleAdapter(this, arrayList, | ||
android.R.layout.simple_list_item_2, new String[] { | ||
"word", "explain" }, new int[] { | ||
android.R.id.text1, android.R.id.text2 }); | ||
Intent intent1 = new Intent(this, MainActivity.class); | ||
intent.putExtra("word", word); | ||
intent.putExtra("explain", explain); | ||
startActivity(intent1); | ||
EditWord.this.finish(); | ||
} | ||
} | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901214/EditWord.java.bak
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,71 @@ | ||
package com.example.dictionary; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.text.TextUtils; | ||
import android.view.View; | ||
import android.view.View.OnClickListener; | ||
import android.view.Window; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
|
||
import com.example.diy.Word; | ||
|
||
public class EditWord extends Activity implements OnClickListener { | ||
private String action; | ||
private EditText zhushi; | ||
private EditText meanning; | ||
private Button confirm; | ||
private Button cancel; | ||
|
||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
// �������ر��� | ||
requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
setContentView(R.layout.edit); | ||
Bundle bundle = this.getIntent().getExtras(); | ||
action = bundle.getString("action"); | ||
zhushi = (EditText) findViewById(R.id.zhushi); | ||
meanning = (EditText) findViewById(R.id.meanning); | ||
|
||
initWidgets(); | ||
} | ||
|
||
private void initWidgets() { | ||
// spelling�ǵ��ʣ�meanning�ǽ��ͣ�confirm��ȷ����cancel��ȡ�� | ||
zhushi = (EditText) findViewById(R.id.zhushi); | ||
meanning = (EditText) findViewById(R.id.meanning); | ||
confirm = (Button) findViewById(R.id.button1); | ||
cancel = (Button) findViewById(R.id.button2); | ||
cancel.setOnClickListener(this); | ||
confirm.setOnClickListener(this); | ||
if (action.equals("edit")) { | ||
} | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
// TODO Auto-generated method stub | ||
|
||
String word = meanning.getText().toString().trim(); | ||
String explain = zhushi.getText().toString().trim(); | ||
if (v == cancel) { | ||
finish(); | ||
} | ||
if (v == confirm) { | ||
if (meanning.getText().toString().equals("") | ||
|| zhushi.getText().toString().equals("")) { | ||
Toast.makeText(EditWord.this, "��Ϣ����Ϊ��", Toast.LENGTH_SHORT).show(); | ||
} | ||
|
||
else { | ||
Intent intent = new Intent(this, NoteBook.class); | ||
intent.putExtra("word", word); | ||
intent.putExtra("explain", explain); | ||
startActivity(intent); | ||
} | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901214/HomeActivity.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,53 @@ | ||
package com.example.dictionary; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.view.Menu; | ||
import android.view.Window; | ||
import android.view.WindowManager; | ||
|
||
public class HomeActivity extends Activity { | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
//设置隐藏标题栏 | ||
requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
//设置全屏 | ||
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, | ||
WindowManager.LayoutParams.FLAG_FULLSCREEN); | ||
setContentView(R.layout.home); | ||
|
||
new Thread(new Runnable(){ | ||
|
||
@Override | ||
public void run() { | ||
// TODO Auto-generated method stub | ||
try { | ||
Thread.sleep(1000); | ||
shiftActivityToHome(); | ||
} catch (InterruptedException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
}).start(); | ||
|
||
} | ||
|
||
private void shiftActivityToHome(){ | ||
Intent intent=new Intent(HomeActivity.this,MainActivity.class); | ||
startActivity(intent); | ||
//把当前也关闭 | ||
HomeActivity.this.finish(); | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
// Inflate the menu; this adds items to the action bar if it is present. | ||
getMenuInflater().inflate(R.menu.main, menu); | ||
return true; | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901214/MainActivity.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,47 @@ | ||
package com.example.dictionary; | ||
import android.os.Bundle; | ||
import android.app.TabActivity; | ||
import android.content.Intent; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.Window; | ||
import android.view.WindowManager; | ||
import android.widget.TabHost; | ||
|
||
public class MainActivity extends TabActivity { | ||
TabHost mTabHost; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
// 设置隐藏标题 | ||
requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
// 设置全屏 | ||
/* | ||
* this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, | ||
* WindowManager.LayoutParams.FLAG_FULLSCREEN); | ||
*/ | ||
// 显示的布局是dier | ||
setContentView(R.layout.dier); | ||
// 取得TabHost对象 | ||
mTabHost = getTabHost(); | ||
// 将类OfflineQuery赋给intent,以便连接到这个页面上 | ||
Intent intent = new Intent().setClass(this, OfflineQuery.class); | ||
// 新建一个newTabSpec(newTabSpec) | ||
// 设置其标签和图标(setIndicator) | ||
// 设置内容(setContent) | ||
mTabHost.addTab(mTabHost.newTabSpec("tab1") | ||
.setIndicator("", getResources().getDrawable(R.drawable.img1)) | ||
.setContent(intent)); | ||
Intent intent1 = new Intent().setClass(this, OnlineQuery.class); | ||
mTabHost.addTab(mTabHost.newTabSpec("tab2") | ||
.setIndicator("", getResources().getDrawable(R.drawable.img2)) | ||
.setContent(intent1)); | ||
Intent intent2 = new Intent().setClass(this, NoteBook.class); | ||
mTabHost.addTab(mTabHost.newTabSpec("tab3") | ||
.setIndicator("", getResources().getDrawable(R.drawable.img3)) | ||
.setContent(intent2)); | ||
mTabHost.setCurrentTab(0); | ||
|
||
} | ||
} |
Oops, something went wrong.