package com.hui.weblab;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.sqlException;
import java.sql.Statement;
import java.util.ArrayList;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.sqlException;
import bean.bilibili;
public class ScActivity extends AppCompatActivity {
ArrayList<bilibili> bilibiliArrayList=null;
/*
public ArrayList<bilibili> run() {
String diver = "com.MysqL.jdbc.Driver";
//加入utf-8是为了后面往表中输入中文,表中不会出现乱码的情况
String url = "jdbc:MysqL://10.99.116.217:3306/exercise";
String user = "qc";//用户名
String password = "123456";//密码
/*
* 连接数据库10.99.116.217
* */
/*
try {
Class.forName(diver);
} catch (ClassNotFoundException e) {
e.printstacktrace();
}
Connection conn=null;
try {
conn = DriverManager.getConnection(url, user, password);
} catch (sqlException e) {
e.printstacktrace();
}
Statement st=null;
ResultSet rs=null;
ArrayList<bilibili> bilibiliArrayList1=null;
String sql = "select * from bilibili";
try {
st = conn.createStatement();
rs = st.executeQuery(sql);
while (rs.next()) {
bilibili bi = new bilibili();
bi.setAuthor(rs.getString("author"));
bi.setTitle(rs.getString("title"));
bi.setId(rs.getInt("id"));
bilibiliArrayList1.add(bi);
System.out.print(bi.getId());
}
st.close();
conn.close();
System.out.println("连接数据库成功");
} catch (sqlException e) {
e.printstacktrace();
System.out.println("连接数据库失败");
}
return bilibiliArrayList1;
}*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sc);
/*
Connection conn=null;
Statement st=null;
ResultSet rs=null;
*/
// bilibiliArrayList=run();
String[] str= {"美丽科学BOS","爆炸实验室BoomLab","宝藏资源库","化学小莫","白小白很不乖","奇奇实验坊","龙虾麻麻的宝藏育儿库","唐唐频道","魔力科学小实验","H2元素实验室","氟氟今天吃什么"};
String[] url={"https://www.bilibili.com/video/BV1oa4y1x7Wr?spm_id_from=333.337.search-card.all.click","https://www.bilibili.com/video/BV1zW411B7Q1?spm_id_from=333.337.search-card.all.click", "https://www.bilibili.com/video/BV1Qv4y1N7DL?spm_id_from=333.337.search-card.all.click","https://www.bilibili.com/video/BV1c4411r7fB?spm_id_from=333.337.search-card.all.click","https://www.bilibili.com/video/BV1Ei4y1Q75M?spm_id_from=333.337.search-card.all.click","https://www.bilibili.com/video/BV1Hh411B7Sa?spm_id_from=333.337.search-card.all.click","https://www.bilibili.com/video/BV1yF411B7LV?spm_id_from=333.337.search-card.all.click","https://www.bilibili.com/video/BV1bb411E7TY?spm_id_from=333.337.search-card.all.click"};
// int i=0;
/* for(bilibili it : bilibiliArrayList)
{
str[i++]=it.getTitle();
}*/
ArrayAdapter<String> adapter=new ArrayAdapter<String>(ScActivity.this,
android.R.layout.simple_list_item_1,str);
ListView listView=(ListView)findViewById(R.id.sc_lv);
listView.setAdapter(adapter);
listView.setonItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Intent intent= new Intent();
intent.setAction("android.intent.action.VIEW");
Uri content_url = Uri.parse(url[arg2]);
intent.setData(content_url);
startActivity(intent);
}
});
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。