Skip to content

Commit

Permalink
修正部分代码
Browse files Browse the repository at this point in the history
  • Loading branch information
mazixuan committed Jun 30, 2019
1 parent 1c01c88 commit 32e8d35
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 13 deletions.
Binary file modified Android基础UI开发new.key
Binary file not shown.
Binary file removed deprecated-chapter1-master/Android基础UI开发.pdf
Binary file not shown.
9 changes: 4 additions & 5 deletions deprecated-chapter1-master/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
<activity android:name=".v2.CreateDemoActivity">
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name=".xmlparser.XmlActivity"/>
<activity android:name=".lifecycle.LifeCycleActivity"/>
Expand Down Expand Up @@ -42,11 +46,6 @@
<activity android:name=".view.RelativeLayoutActivity"/>

<activity android:name=".v2.CreateDemoActivityV2">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

Expand Down
1 change: 1 addition & 0 deletions deprecated-chapter1-master/chapter1/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:appcompat-v7:28.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".OpenedIntentActivity">
</activity>
<activity android:name=".IntentActivity">
</activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.ss.android.ugc.chapter1;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class IntentActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_intent);

findViewById(R.id.txt_intent).setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
Intent intent = new Intent(IntentActivity.this, OpenedIntentActivity.class);
intent.putExtra("data", "我是IntentActivity");
startActivity(intent);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends Activity {

Expand All @@ -14,5 +16,10 @@ protected void onCreate(Bundle savedInstanceState) {
ListView listView = findViewById(R.id.listview);
ListViewBaseAdapter adapter = new ListViewBaseAdapter(this);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(MainActivity.this, "点击了第:" + position, Toast.LENGTH_LONG).show();
}
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.ss.android.ugc.chapter1;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

public class OpenedIntentActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_opened_intent);
String data = getIntent().getStringExtra("data");
Toast.makeText(this, data, Toast.LENGTH_LONG).show();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="https://schemas.android.com/apk/res/android"
xmlns:tools="https://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".IntentActivity">

<TextView
android:id="@+id/txt_intent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="点击事件"
android:textSize="18sp"/>

</android.support.constraint.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="https://schemas.android.com/apk/res/android"
xmlns:app="https://schemas.android.com/apk/res-auto"
xmlns:tools="https://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".OpenedIntentActivity">

</android.support.constraint.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme">
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@

/**
* 作业1:
* Logcat在屏幕旋转的时候 #onStop() #onDestroy()会展示出来
* 但我们的 mLifecycleDisplay 由于生命周期的原因(Tips:执行#onStop()之后,UI界面我们是看不到的)并没有展示
* 在原有@see Exercises1 基础上如何补全它,让其跟logcat的展示一样?
* <p>
* Tips:思考用比Activity的生命周期要长的来存储? (比如:application、static变量)
* 打印出Activity屏幕切换 Activity会执行什么生命周期?
*/
public class Exercises1 extends AppCompatActivity {


@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down

0 comments on commit 32e8d35

Please sign in to comment.