bashgid/android/src/fishrungames/bashgid/NewsRecordFragment.java

50 lines
1.4 KiB
Java

package fishrungames.bashgid;
import fishrungames.bashgid.core.ImageManager;
import fishrungames.bashgid.core.NewsManager.NewsRecord;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;
public class NewsRecordFragment extends Fragment
{
NewsRecord newsRecord;
public NewsRecordFragment(NewsRecord newsRecord)
{
this.newsRecord = newsRecord;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_news_record_page, container, false);
TextView titleTextView = (TextView) rootView.findViewById(R.id.titleTextView);
titleTextView.setText(newsRecord.title);
ImageView imageView = (ImageView) rootView.findViewById(R.id.imageView);
ImageManager.getInstance().ApplyImageToImageView(imageView, newsRecord.imageId);
WebView webView = (WebView) rootView.findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(false);
String htmlCode = "<html><body>" + newsRecord.description + "</body></html>";
webView.loadDataWithBaseURL(null, htmlCode, "text/html", "UTF-8", null);
return rootView;
}
}