Skip to content

Commit

Permalink
hzuapps#5 hzuapps#56 第五次实验
Browse files Browse the repository at this point in the history
  • Loading branch information
HuaStarOS committed Dec 6, 2020
1 parent 2074e6d commit 3c7a9f4
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions students/net1814080903325/Net1814080903325Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,53 @@

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public class Net1814080903325Activity extends AppCompatActivity {

private ImageView mImageView;
private TextView mTextView;
private String FileName = "play_state";

@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_net1814080903325);
init();
}

private void init() {
mImageView = this.findViewById(R.id.detail_play_control);
mTextView = this.findViewById(R.id.detail_play_control);
mImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//修改当前的播放状态
mTextView.setText("正在播放");
//修改ui更新播放状态
mImageView.setImageResource(R.mipmap.pause_black_normal);
//获取当前的播放状态
String text = mTextView.getText().toString();
//将当前播放状态保存到sp里头去
FileOutputStream fileOutputStream = null;
try {
fileOutputStream = openFileOutput(FileName, Context.MODE_PRIVATE);
fileOutputStream.write(text.getBytes());
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}


}
});
}
}

0 comments on commit 3c7a9f4

Please sign in to comment.