【发布时间】:2015-02-28 10:11:42
【问题描述】:
我如何从一个 aSyncTask 类返回一个对象的 ArrayList 和一个字符串。
aSyncTask 使用 jsoup 检索表的 3 个元素,该表被放入新的 Employee 类中,然后作为数组列表返回到 MainActivity,但我希望它也为该特定表返回一个字符串。
主活动
public void onButtonClick()
new GetEmployee() {
@Override
protected void onPostExecute(ArrayList<Employee> list) {
Intent intent = new Intent(getApplicationContext(), EmployeeActivity.class);
intent.putParcelableArrayListExtra("empClass", list);
//i want to also pass the title of the Employee table aswell as the list,
//after running the aSyncTask
startActivity(intent);
}
}.execute();
获取员工
public Employee empObj;
@Override
protected ArrayList<Employee> doInBackground(String... params)
{
ArrayList<Employee> emp = new ArrayList<Employee>();
String title;
try {
//get employee details from table using JSoup
//get employee table title using JSoup
empObj = new Emp(...);
emp.add(empObj);
return emp;
} catch (IOException e) {
e.printStackTrace();
}
return emp;
我如何从这里返回一个字符串以及一个员工的 ArrayList
【问题讨论】:
-
在执行后将数组列表返回到您的方法或任何东西。
-
我在检查后更新了答案。
标签: java android android-asynctask