2013-10-16 66 views
0

我沒有從活動得到結果返回給片段startActivityForResult從適配器到活動沒有得到結果返回給片段

這是我的福爾摩斯片段代碼

public class AlphabeticalListFragment extends SherlockFragment { 
. 
. 
. 
public void setAdapter(){ 
    adapter = new ListviewAlphabetAdapter(context, alphabet_data); 
    lv_list.setAdapter(adapter); 
    } 
. 
. 
@Override 
public void onActivityResult(int requestCode, int resultCode, Intent data) { 
    super.onActivityResult(requestCode, resultCode, data); 
      Toast.makeText(context, "RESULT : " + requestCode + "-" + resultCode, 
         Toast.LENGTH_SHORT).show(); 
      } 
     } 

我的適配器代碼是

public class ListviewAlphabetAdapter extends BaseAdapter{ 
. 
. 

    @Override 
    public View getView(final int position, View convertView, ViewGroup parent) { 
     convertView = mInflater.inflate(R.layout.template_list_letter_view, 
       null); 
      holder.ll_store_data.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i_dialog = new Intent(context, 
         DialogStoreAllActivity.class); 
       i_dialog.putExtra("id", alphabet_data.get(position).getI()); 
       ((Activity) context).startActivityForResult(i_dialog, 500); 
      } 
     }); 
     return convertView; 
    } 
} 

在活動

public class DialogStoreAllActivity extends Activity{ 
. 
. 
// In onClick function of a button 
setResult(RESULT_OK, (i_groups).setAction("ok")); 
. 
} 

我米沒有得到結果在片段

回答

1

寫這樣

public void startCommentActivity(Intent i){ 
startActivityForResult(i, 100); 

在活動類functon}

調用它在適配器類mActivity.startCommentActivity(意向);