コードは動作するようになりましたが、実際に何をしているのかわかりません。私のアプリは RSS リーダーで、メイン コンテンツはwithオブジェクトFragment
を含む にあります。リスト項目をクリックすると、RSS からリンクされた Web サイトが開きます。ListView
NewsStory
Intent
ここでの問題は、ここが理解できないことです。Intent
これは、これまでに使用した方法ではありませんIntent
。
また、向きを変えると、元のプロファイルFragment
が画面の左半分を占め、リンク先の Web ページが画面の右半分を占めるようにする必要があります。私はそれをいじくり回しましたが、役に立ちませんでした。Fragment
向きの変更について少し調べてみましたが、 s を使用すると、すべての動作が常に変わるように感じます。とにかく、ここにFragment
コードがあります。どんな考えでも大歓迎です。
public class HeadlineFragment extends Fragment {
EditText input;
Button search;
ListView headlines;
NewsDataSource ds;
public HeadlineFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_headline,container,false);
input = (EditText)v.findViewById(R.id.txtInput);
search = (Button)v.findViewById(R.id.btnSearch);
headlines = (ListView)v.findViewById(R.id.listView);
try {
ds = new NewsDataSource();
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
headlines.setAdapter(new NewsDataSourceAdapter(this.getActivity(), ds));
headlines.setOnItemClickListener(new AdapterView.OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent,View view, int position, long id)
{
String url = NewsDataSource.stories[position].getLink();
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
return v;
}
/*
@Override
public void onConfigurationChanged(Configuration newConfig){
super.onConfigurationChanged(newConfig);
}
*/
}