android listview全屏,如何通过单击Android教程应用程序中的ListView全屏打开图像

以下是我到目前为止所得到的.该错误是每当我单击ListItem时发生以下错误

Unfortunately app has stopped working

ListViewAdapter.class

public class ListViewAdapter extends BaseAdapter {

protected static long[] itemVie;

// Declare Variables

Context context;

LayoutInflater inflater;

ArrayList> data;

ImageLoader imageLoader;

HashMap resulta = new HashMap();

public ListViewAdapter(Context context,

ArrayList> arraylist) {

this.context = context;

data = arraylist;

imageLoader = new ImageLoader(context);

}

@Override

public int getCount() {

return data.size();

}

@Override

public Object getItem(int position) {

return null;

}

@Override

public long getItemId(int position) {

return 0;

}

@SuppressLint("ViewHolder")

public View getView(final int position, View convertView, ViewGroup parent) {

// Declare Variables

TextView albname;

ImageView portimages;

inflater = (LayoutInflater) context

.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View itemVie = inflater.inflate(R.layout.list_item, parent, false);

// Get the position

resulta = data.get(position);

// Locate the TextViews in listview_item.xml

albname = (TextView) itemVie.findViewById(R.id.name);

portimages = (ImageView) itemVie.findViewById(R.id.portImg);

albname.setText(resulta.get(Portfolio.TAG_TITLE));

imageLoader.DisplayImage(resulta.get(Portfolio.TAG_IMAGE), portimages);

// Capture ListView item click

itemVie.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View arg0) {

resulta = data.get(position);

Intent intent = new Intent(context, FullScreenImage.class);

intent.putExtra("albname", resulta.get(Portfolio.TAG_TITLE));

intent.putExtra("portimages",resulta.get(Portfolio.TAG_IMAGE));

context.startActivity(intent);

}

});

return itemVie;

}

}

FullScreenImage.class

package com.example.truzzapp;

public class FullScreenImage extends Activity implements OnItemSelectedListener {

ImageView image;

TextView txt;

String port_name;

String port_image;

ProgressDialog pDialog;

ImageLoader imageLoader = new ImageLoader(this);

protected void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.fullimage);

Intent i = getIntent();

port_name = i.getStringExtra("albname");

port_image = i.getStringExtra(“ portimages”);

txt = (TextView) findViewById(R.id.PortHeading);

image = (ImageView) findViewById(R.id.portFullImage);

txt.setText(port_name);

imageLoader.DisplayImage(port_image, image);

}

@Override

public void onItemSelected(AdapterView> arg0, View arg1, int arg2,

long arg3) {

// TODO Auto-generated method stub

}

@Override

public void onNothingSelected(AdapterView> arg0) {

// TODO Auto-generated method stub

}

}

Logcat错误

12-02 13:42:45.725: E/AndroidRuntime(1129): FATAL EXCEPTION: main

12-02 13:42:45.725: E/AndroidRuntime(1129): android.app.SuperNotCalledException: Activity {com.example.truzzapp/com.example.truzzapp.FullScreenImage} did not call through to super.onCreate()

12-02 13:42:45.725: E/AndroidRuntime(1129): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025)

12-02 13:42:45.725: E/AndroidRuntime(1129): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)

12-02 13:42:45.725: E/AndroidRuntime(1129): at android.app.ActivityThread.access$600(ActivityThread.java:130)

12-02 13:42:45.725: E/AndroidRuntime(1129): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)

12-02 13:42:45.725: E/AndroidRuntime(1129): at android.os.Handler.dispatchMessage(Handler.java:99)

12-02 13:42:45.725: E/AndroidRuntime(1129): at android.os.Looper.loop(Looper.java:137)

12-02 13:42:45.725: E/AndroidRuntime(1129): at android.app.ActivityThread.main(ActivityThread.java:4745)

12-02 13:42:45.725: E/AndroidRuntime(1129): at java.lang.reflect.Method.invokeNative(Native Method)

12-02 13:42:45.725: E/AndroidRuntime(1129): at java.lang.reflect.Method.invoke(Method.java:511)

12-02 13:42:45.725: E/AndroidRuntime(1129): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)

12-02 13:42:45.725: E/AndroidRuntime(1129): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)

12-02 13:42:45.725: E/AndroidRuntime(1129): at dalvik.system.NativeStart.main(Native Method)

解决方法:

注意logcat:没有通过super.onCreate()进行调用

您忘记了调用super.onCreate(savedInstanceState);在setContentView之前

标签:listview,imageview,android

来源: https://codeday.me/bug/20191121/2048291.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值