diff --git a/app/src/main/java/edu/hzuapps/androidworks/homeworks/BackActivity.java b/app/src/main/java/edu/hzuapps/androidworks/homeworks/BackActivity.java deleted file mode 100644 index 70c51b53..00000000 --- a/app/src/main/java/edu/hzuapps/androidworks/homeworks/BackActivity.java +++ /dev/null @@ -1,49 +0,0 @@ -package edu.hzuapps.androidworks.homeworks; - -import android.os.Bundle; -import android.support.v7.app.ActionBarActivity; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; - -import edu.hzuapps.androidworks.R; - -/** - * 实现的默认返回按钮,所有作业可继续此类. - */ -public class BackActivity extends ActionBarActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_back); - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.menu_subactivity, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - int id = item.getItemId(); - if (id == R.id.action_back) { - finish(); - return true; - } - return super.onOptionsItemSelected(item); - } - - @Override - protected void onStop() { - super.onStop(); - Log.i(this.getClass().getSimpleName(), "停止!"); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - Log.i(this.getClass().getSimpleName(), "回收!"); - } -} diff --git a/app/src/main/java/edu/hzuapps/androidworks/homeworks/Net1314080903212Activity.java b/app/src/main/java/edu/hzuapps/androidworks/homeworks/Net1314080903212Activity.java deleted file mode 100644 index 9ad0412f..00000000 --- a/app/src/main/java/edu/hzuapps/androidworks/homeworks/Net1314080903212Activity.java +++ /dev/null @@ -1,48 +0,0 @@ -package edu.hzuapps.androidworks.homeworks; - -import android.os.Bundle; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.view.ViewGroup; -import android.widget.LinearLayout; -import android.widget.TextView; - -import edu.hzuapps.androidworks.R; -//import edu.hzuapps.androidworks.homeworks.Net1314080903212; - -/** - * Created by dell on 2016/3/21. - */ -public class Net1314080903212 extends BackActivity { - - private LinearLayout mTextContainer; - - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - -// TextView textView = new TextView(this); -// textView.setText("isshe"); - - createViewInJava(); - setContentView(mTextContainer); - -// 默认使用XML创建的View -// setContentView(R.layout.net1314080903212); - -} - - private void createViewInJava() { - mTextContainer = new LinearLayout(this); - ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams( // - ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - mTextContainer.setLayoutParams(layoutParams); - mTextContainer.setOrientation(LinearLayout.HORIZONTAL); - - TextView textView = new TextView(this); - textView.setText("isshe: Net13140809032122"); - - mTextContainer.addView(textView); - } - -} diff --git a/app/src/main/java/edu/hzuapps/androidworks/homeworks/com123456/Com123456Activity.java b/app/src/main/java/edu/hzuapps/androidworks/homeworks/com123456/Com123456Activity.java deleted file mode 100644 index 74eae290..00000000 --- a/app/src/main/java/edu/hzuapps/androidworks/homeworks/com123456/Com123456Activity.java +++ /dev/null @@ -1,41 +0,0 @@ -package edu.hzuapps.androidworks.homeworks.com123456; - -import android.os.Bundle; -import android.support.v7.app.ActionBarActivity; -import android.view.View; -import android.widget.Button; - -import edu.hzuapps.androidworks.R; -import edu.hzuapps.androidworks.homeworks.BackActivity; - -public class Com123456Activity extends BackActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_com123456); - - Button closeBtn = (Button) findViewById(R.id.button_close); - closeBtn.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - finish(); - } - }); - } - - @Override - protected void onStart() { - super.onStart(); - } - - @Override - protected void onPause() { - super.onPause(); - } - - @Override - protected void onStop() { - super.onStop(); - } -} diff --git a/app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901140/MainActivity.java b/app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901140/MainActivity.java new file mode 100644 index 00000000..0b545a4c --- /dev/null +++ b/app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901140/MainActivity.java @@ -0,0 +1,128 @@ +package edu.hzuapps.androidworks; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.ActionBarActivity; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.RelativeLayout; + +import edu.hzuapps.androidworks.examples.AbsoluteLayoutActivity; +import edu.hzuapps.androidworks.examples.ActivityBasicActivity; +import edu.hzuapps.androidworks.examples.BroadcastReceiverActivity; +import edu.hzuapps.androidworks.examples.ContentProviderActivity; +import edu.hzuapps.androidworks.examples.FileSelectActivity; +import edu.hzuapps.androidworks.examples.FileShareActivity; +import edu.hzuapps.androidworks.examples.FileStorageActivity; +import edu.hzuapps.androidworks.examples.FragmentDemoActivity; +import edu.hzuapps.androidworks.examples.FrameLayoutActivity; +import edu.hzuapps.androidworks.examples.GridViewActivity; +import edu.hzuapps.androidworks.examples.LinearLayoutActivity; +import edu.hzuapps.androidworks.examples.ListViewActivity; +import edu.hzuapps.androidworks.examples.NetworkActivity; +import edu.hzuapps.androidworks.examples.RelativeLayoutActivity; +import edu.hzuapps.androidworks.examples.ServiceDemoActivity; +import edu.hzuapps.androidworks.examples.SharedPreferencesActivity; +import edu.hzuapps.androidworks.examples.TableLayoutActivity; +import edu.hzuapps.androidworks.examples.ViewBasicActivity; +import edu.hzuapps.androidworks.examples.ViewDemoActivity; +import edu.hzuapps.androidworks.homeworks.BackActivity; +import edu.hzuapps.androidworks.homeworks.com123456.Com123456Activity; + +public class MainActivity extends ActionBarActivity { + + public static final String TAG = MainActivity.class.getSimpleName(); + + String mName; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); +// TODO 解析学生实验目录 + setContentView(R.layout.activity_main); + + // 显示例子按钮 + prepareExampleButton(R.id.button_activitybasic); + prepareExampleButton(R.id.button_viewbasic); + prepareExampleButton(R.id.button_fragmentdemo); + prepareExampleButton(R.id.button_servicedemo); + prepareExampleButton(R.id.button_broadcastdemo); + prepareExampleButton(R.id.button_contentprovidedemo); + prepareExampleButton(R.id.button_viewdemo); + + // 随机显示一位同学的作业 + prepareExampleButton(R.id.button_random); + + } + + @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_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) { + System.out.println("Yes"); +// Log.i(this.getClass().getSimpleName(), "View created!"); + Log.i("标题", "信息"); + return true; + } + + return super.onOptionsItemSelected(item); + } + + private void openActivity(Activity activity, Class activityClass) { + Intent intent = new Intent(activity, activityClass); + activity.startActivity(intent); + } + + private void prepareExampleButton(final int buttonId) { + final Activity thisActivity = this; + Button button = (Button) findViewById(buttonId); + if (button != null) { + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + openActivity(thisActivity, getActivity(buttonId)); + } + }); + } else { + Log.e(TAG, "按钮不存在: " + buttonId); + } + } + + private Class getActivity(int id) { + if (R.id.button_activitybasic == id) { + return ActivityBasicActivity.class; + } else if (R.id.button_viewbasic == id) { + return ViewBasicActivity.class; + } else if (R.id.button_fragmentdemo == id) { + return FragmentDemoActivity.class; + } else if (R.id.button_servicedemo == id) { + return ServiceDemoActivity.class; + } else if (R.id.button_broadcastdemo == id) { + return BroadcastReceiverActivity.class; + } else if (R.id.button_contentprovidedemo == id) { + return ContentProviderActivity.class; + } else if (R.id.button_viewdemo == id) { + return ViewDemoActivity.class; + } else if (R.id.button_random == id) { + return FileShareActivity.class; + } else { + return BackActivity.class; + } + } +} diff --git a/app/src/main/java/edu/hzuapps/androidworks/homeworks/net123456/Net123456Activity.java b/app/src/main/java/edu/hzuapps/androidworks/homeworks/net123456/Net123456Activity.java deleted file mode 100644 index c001bf8d..00000000 --- a/app/src/main/java/edu/hzuapps/androidworks/homeworks/net123456/Net123456Activity.java +++ /dev/null @@ -1,52 +0,0 @@ -package edu.hzuapps.androidworks.homeworks.net123456; - -import android.content.Context; -import android.os.Bundle; -import android.support.v7.app.ActionBarActivity; -import android.util.AttributeSet; -import android.util.Log; -import android.view.View; - -import edu.hzuapps.androidworks.R; -import edu.hzuapps.androidworks.homeworks.BackActivity; - -public class Net123456Activity extends BackActivity { - - public static final String TAG = Net123456Activity.class.getSimpleName(); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - // 填充活动|屏幕的内容 - setContentView(R.layout.activity_net123456); - } - - @Override - public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { - return super.onCreateView(parent, name, context, attrs); - } - - @Override - protected void onPause() { - super.onPause(); - Log.i(TAG, "onPause."); - } - - @Override - protected void onStart() { - super.onStart(); - Log.i(TAG, "onStart."); - } - - @Override - protected void onRestart() { - super.onRestart(); - Log.i(TAG, "onRestart."); - } - - @Override - protected void onStop() { - super.onStop(); - Log.i(TAG, "onStop."); - } -} diff --git a/edu.hzuapps.androidworks.homeworks.com1314080901211/MainActivity.java b/edu.hzuapps.androidworks.homeworks.com1314080901211/MainActivity.java deleted file mode 100644 index f201412d..00000000 --- a/edu.hzuapps.androidworks.homeworks.com1314080901211/MainActivity.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.homeworks.androidworks.hzuapps.edu.desktopmemo; - -import android.os.Bundle; -import android.support.v7.app.ActionBarActivity; -import android.view.Menu; -import android.view.MenuItem; - -public class MainActivity extends ActionBarActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); - } - - @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_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); - } -} diff --git "a/edu.hzuapps.androidworks.homeworks.com1314080901225/#43\344\273\277\344\275\240\347\224\273\346\210\221\347\214\234\347\224\273\346\235\277\345\212\237\350\203\275.txt" "b/edu.hzuapps.androidworks.homeworks.com1314080901225/#43\344\273\277\344\275\240\347\224\273\346\210\221\347\214\234\347\224\273\346\235\277\345\212\237\350\203\275.txt" deleted file mode 100644 index 89cfb5c7..00000000 --- "a/edu.hzuapps.androidworks.homeworks.com1314080901225/#43\344\273\277\344\275\240\347\224\273\346\210\221\347\214\234\347\224\273\346\235\277\345\212\237\350\203\275.txt" +++ /dev/null @@ -1,4 +0,0 @@ -1ҿڻϻκζ -2ı仭ɫ -3ı仭ʴС -4ͼƬ湦 \ No newline at end of file