2017-04-13 9 views
-1

StringをdoInBackgroundに渡してArrayListをonPostExecuteに戻す方法 何を私はAsyntask doInBackgroundとonPostExecuteにhtml URLを渡したいと思っています。私はUIでやりたいことがあります。私はこのStringをAsyncTask doInBackgroundに渡してArrayListを返す方法<String>をonPostExecute

new calc_stanica().execute("where we send URL as String");// 

とAsynTaskような何か試してみたい

public class calc_stanica extends AsyncTask<String, Void, ArrayList<String>> { 
    ProgressDialog dialog; 

    @Override 
    protected void onPreExecute() {   

    } 

    protected ArrayList<String> doInBackground(ArrayList<String>... passing) {  

     // here i want to from URL String pars data to ArrayList<String>   

     return ArrayList<String>; 

    } 

    protected void onPostExecute(ArrayList<String> result) { 

    // do with ArrayList<String>   

    } 
} 
+0

が動作していない何かありますか?あなたの質問は何ですか ? –

答えて

0
public class calc_stanica extends AsyncTask<String, Void, ArrayList<String>> { 
    ProgressDialog dialog; 

    @Override 
    protected void onPreExecute() {   

    } 

    protected ArrayList<String> doInBackground(String... passing) {  
String URLStr=passing[0];//as you are passing 1 url only so this will work for u  
ArrayList<String> arraylist=new ArrayList<String>(); 
     // here u do the things u wana do and add the String data to ArrayList<String> and return   

     return arraylist; 

    } 

    protected void onPostExecute(ArrayList<String> result) { 

    // do with ArrayList<String>   

    } 
} 
+0

なぜ私はそれが私は空の配列をonPostExecuteで好きですか? – smiljka

+0

あなたが行っていることをコードを共有することはできますか?あなたがarraylistに文字列データを追加していない場合、uだけが空になっている可能性があります –

関連する問題