3 개의 탭이있는 슬라이딩 레이아웃을 사용하고 있습니다. 첫 번째 탭에서 URL의 이미지를 표시하려고합니다.Android - SlidingTabLayout에 콘텐츠 표시
이미지를 단일보기로로드하려고 시도했지만 정상적으로 작동했습니다. 첫 번째 탭에 대한
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=“myproject.FirstTab”>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="TEST LOADING IMAGE"
android:id="@+id/textView"
android:layout_marginTop="30dp"
android:layout_centerHorizontal="true" />
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:id="@+id/imageView"
android:layout_below="@+id/textView"
android:layout_centerHorizontal="true"
android:layout_marginTop="66dp" />
</RelativeLayout>
자바 (FirstTab.java) : 여기
public class FirstTab extends ActionBarActivity {
Bitmap b;
ImageView img;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
img = (ImageView) findViewById(R.id.imageView);
information info = new information();
info.execute("");
}
public class information extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... arg0) {
try {
URL url = new URL("https://si.wsj.net/public/resources/images/BN-BY925_mag041_OZ_20140318165119.jpg");
InputStream is = new BufferedInputStream(url.openStream());
b = BitmapFactory.decodeStream(is);
} catch (Exception e) {
}
return null;
}
@Override
protected void onPostExecute(String result) {
img.setImageBitmap(b);
}
}
}
내 조각 (LayoutInflater에서이 여기에
내 첫 번째 탭 (activity_first.xml)에 대한 XML이다. java) :위의 결과는 텍스트보기 만 표시됩니다.