代码拉取完成,页面将自动刷新
package com.example.sy64;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.util.StringTokenizer;
public class SecondActivity extends Activity implements View.OnClickListener {
private LinearList linearList=new LinearList();
@Override
protected void onCreate(Bundle savedinstance) {
super.onCreate(savedinstance);
setContentView(R.layout.activity_second);
Intent a=getIntent();
String str=a.getStringExtra("h");
try {
Linear(str);
} catch (IOException e) {
e.printStackTrace();
}
}
public void Linear(String str) throws IOException {
StringTokenizer str1=new StringTokenizer(str);
while(str1.hasMoreTokens()){
linearList.Add(new LinearNode(Integer.valueOf(str1.nextToken())));
}
String result="当前链表元素个数为:\n"+linearList.getnLengChong()+"\n元素:"+linearList.toString()+"\n";
InputStream inputStream=getAssets().open("test.txt");
int size=inputStream.available();
byte[] a=new byte[size];
inputStream.read(a);
inputStream.close();
String content=new String(a);
StringTokenizer stringTokenizer=new StringTokenizer(content);
int x1=Integer.valueOf(stringTokenizer.nextToken());
int x2=Integer.valueOf(stringTokenizer.nextToken());
linearList.AddJ(linearList.Count(4).getElement(),x1);
linearList.AddH(x2);
String result1="加入数1数2,当前链表元素个数为:\n"+linearList.getnLengChong()+"\n元素:"+linearList.toString()+"\n";
linearList.SubJ(x1);
String result2="删去数1,当前链表元素个数为:\n"+linearList.getnLengChong()+"\n元素:"+linearList.toString()+"\n";
TextView text=(TextView)findViewById(R.id.j);
TextView text1=(TextView)findViewById(R.id.k);
TextView text2=(TextView)findViewById(R.id.b);
text.setText(result);
text1.setText(result1);
text2.setText(result2);
}
@Override
public void onClick(View v) {
TextView a = (TextView) findViewById(R.id.sort);
String str=linearList.Sort();
str+="排序后的链表元素为:\n" + linearList.toString();
a.setText(str);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。