-
Notifications
You must be signed in to change notification settings - Fork 229
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 #1689 from Peiweilu/master
- Loading branch information
Showing
16 changed files
with
192 additions
and
282 deletions.
There are no files selected for viewing
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
27 changes: 0 additions & 27 deletions
27
.../app/src/main/java/edu/hzuapps/androidlabs/com1709081602330/Com1709081602330Activity.java
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
...app/src/main/java/edu/hzuapps/androidlabs/com1709081602330/Com1709081602330Activity2.java
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
...709081602330/app/src/main/java/edu/hzuapps/androidlabs/com1709081602330/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,28 @@ | ||
package edu.hzuapps.androidlabs.com1709081602330; | ||
|
||
import android.content.Intent; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
private Button select_sort; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
Button select_sort = (Button) findViewById(R.id.select_sort); | ||
select_sort.setOnClickListener(new View.OnClickListener(){ | ||
@Override | ||
public void onClick(View v){ | ||
Intent intent = new Intent(MainActivity.this,Sports_sort.class); | ||
startActivity(intent); | ||
} | ||
}); | ||
} | ||
|
||
|
||
} |
92 changes: 92 additions & 0 deletions
92
...1709081602330/app/src/main/java/edu/hzuapps/androidlabs/com1709081602330/Sports_sort.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,92 @@ | ||
package edu.hzuapps.androidlabs.com1709081602330; | ||
|
||
import android.content.Context; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.text.TextUtils; | ||
import android.widget.Button; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.BufferedWriter; | ||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.io.OutputStreamWriter; | ||
|
||
public class Sports_sort extends AppCompatActivity { | ||
private Button basketball; | ||
private Button football; | ||
private Button tennis; | ||
private EditText edit_add_sort; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_sports_sort); | ||
edit_add_sort = (EditText) findViewById(R.id.edit_add_sort); | ||
String inputText = load(); | ||
if (!TextUtils.isEmpty(inputText)) { | ||
edit_add_sort.setText(inputText); | ||
edit_add_sort.setSelection(inputText.length()); | ||
Toast.makeText(this, "Restoring succeeded", Toast.LENGTH_SHORT).show(); | ||
} | ||
} | ||
|
||
//文件存储数据 | ||
@Override | ||
protected void onDestroy(){ | ||
super.onDestroy(); | ||
String inputText = edit_add_sort.getText().toString(); | ||
save(inputText); | ||
} | ||
public void save(String inputText){ | ||
FileOutputStream out = null; | ||
BufferedWriter writer = null; | ||
try{ | ||
out = openFileOutput("data", Context.MODE_PRIVATE); | ||
writer = new BufferedWriter(new OutputStreamWriter(out)); | ||
writer.write(inputText); | ||
} catch (IOException e){ | ||
e.printStackTrace(); | ||
}finally{ | ||
try{ | ||
if (writer != null){ | ||
writer.close(); | ||
} | ||
}catch (IOException e){ | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
//读取数据 | ||
public String load(){ | ||
FileInputStream in = null; | ||
BufferedReader reader = null; | ||
StringBuilder content = new StringBuilder(); | ||
|
||
try{ | ||
in = openFileInput("data"); | ||
reader = new BufferedReader(new InputStreamReader(in)); | ||
String line = ""; | ||
while ((line = reader.readLine()) != null){ | ||
content.append(line); | ||
} | ||
}catch(IOException e){ | ||
e.printStackTrace(); | ||
}finally { | ||
if (reader != null){ | ||
try{ | ||
reader.close(); | ||
}catch(IOException e){ | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
return content.toString(); | ||
} | ||
} |
Binary file not shown.
170 changes: 0 additions & 170 deletions
170
students/com1709081602330/app/src/main/res/drawable/ic_launcher_background.xml
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
31 changes: 31 additions & 0 deletions
31
students/com1709081602330/app/src/main/res/layout/activity_main.xml
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,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".MainActivity"> | ||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="体育比赛直播间" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintLeft_toLeftOf="parent" | ||
app:layout_constraintRight_toRightOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
<Button | ||
android:id="@+id/select_sort" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="选择分类" | ||
/> | ||
<ImageView | ||
android:id="@+id/image_view" | ||
android:layout_height="wrap_content" | ||
android:layout_width="wrap_content" | ||
android:src = "@drawable/img_1" | ||
/> | ||
|
||
|
||
</TableLayout> |
Oops, something went wrong.