クラシック メニュー/詳細フラグメント タブレット アクティビティを作成しています。
私の詳細フラグメントは、外部ライブラリによって生成されたグラフです。このライブラリは、インテントまたはグラフのビューを提供しています。
メニューをクリックすると、グラフを更新したいと思います。
これは私のアクティビティコードです:
public class myActivity extends FragmentActivity {
Context context;
Graphical graphical;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
context = this;
setContentView(R.layout.fragment_suivi_conso_graph);
}
/**
* Called when clicking on the menu Fragment
*/
public void onChooseGraph(UrlAction urlAction){
GraphFragment graphFragment = (GraphFragment) getSupportFragmentManager().findFragmentById(R.id.graph_fragment);
if (graphFragment == null || !graphFragment.isInLayout()) {
Intent intentGraph;
intentGraph = graphical.executeForIntent(this, urlAction);
startActivity(intentGraph);
}
else {
View graphView = graphFragment.loadGraph(urlAction);
// I don't know what to do with this View !
}
}
これは私の詳細フラグメントコードです:
public class GraphFragment extends Fragment {
private Context context;
private Graphical graphical;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
context = this.getActivity();
graphical = new Graphical();
View graphView = null;
graphView = graphical.executeForView(context, UrlAction.CONSO_WEEKS);
return graphView;
}
public View loadGraph(UrlAction urlAction) {
Log.d("GraphFragment","[loadGraph] START");
View graphView = graphical.executeForView(context, urlAction);
//This graphView contains the graph I want to display in my graphFragment
return graphView;
}
}
フラグメント ビューをフラグメントのloadGraph関数にリロードできるかどうかわかりません。または、アクティビティでonChooseGraph関数にそれを行う必要がありますか。
どちらの場合も、更新方法がわかりません。