是一种新的android.the事情是我编写了一个vb代码上传一些数据到SQL服务器,包括一个image.so我想创建一个Android应用程序,通过创建一个下拉列表与主要查看这些数据在数据库中输入..所以每当我从下拉列表中选择一些东西时,它会显示其余的列...我的英语,但我希望你们有这个想法。
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void query2() {
Log.i("Android"," MySQL Connect Example.");
Connection conn = null;
try {
String driver = "net.sourceforge.jtds.jdbc.Driver";
Class.forName(driver).newInstance();
//test = com.microsoft.sqlserver.jdbc.SQLServerDriver.class;
String connString = "jdbc:jtds:sqlserver:// AMD/SQLEXPRESS :1433/***********;encrypt=fasle;user=*******;password=*********;instance=SQLEXPRESS;";
String username = "Shawtari";
String password = "";
conn = DriverManager.getConnection(connString,username,password);
Log.w("Connection","open");
Statement stmt = conn.createStatement();
ResultSet forest = stmt.executeQuery("select * from aspnet_Users");
//Print the data to the console
while(forest.next()){
Log.w("username",forest.getString(3));
}
conn.close();
} catch (Exception e) {
Log.w("Error connection","" + e.getMessage());
}
}
}
答案 0 :(得分:1)
Spinner
显示主要条目,使用ListView
显示列OnItemSelectedListener
添加spinner
。在此listener
中,最好使用JDBC
将AsyncTask
调用作为后台任务。listview
。您可能需要实施custom adapter
ResultSet
,然后解析它以将其提供给listview
。