Java ListView没有';不能显示超过8个图像视图

Java ListView没有';不能显示超过8个图像视图,java,android,listview,imageview,Java,Android,Listview,Imageview,我正在解码使用json收到的服务器请求中的jpeg图像。我用一个自定义的ListView适配器和一点文本来显示它们 对于ListView中的前8个ImageView,图像显示正确,但此后它将不再显示图像(将显示文本)。例如,如果我总共有10个图像,最后两个图像将不会显示在ListView中,但如果我删除前两个图像,最后两个图像将显示,因此不必担心检索实际图像 在我的主活动(NotesActivity)上,我有一个按钮,它指向另一个执行asyntask的活动,在onPostExecute中的异步任

我正在解码使用json收到的服务器请求中的jpeg图像。我用一个自定义的ListView适配器和一点文本来显示它们

对于ListView中的前8个ImageView,图像显示正确,但此后它将不再显示图像(将显示文本)。例如,如果我总共有10个图像,最后两个图像将不会显示在ListView中,但如果我删除前两个图像,最后两个图像将显示,因此不必担心检索实际图像

在我的主活动(NotesActivity)上,我有一个按钮,它指向另一个执行asyntask的活动,在onPostExecute中的异步任务中,它返回到主活动,在主活动中它应该显示更新的列表(它确实显示,除非有8个以上的图像)

我不知道从哪里开始,有什么建议吗

包含ListView的我的活动

public class NotesActivity extends Activity implements OnClickListener {

    String key = "NOTES";
    String key2 = "UPDATE_NOTES";

    Gson gson = new Gson();
    // Notes myNotes = new Notes();
    NotesList myNotes = new NotesList();
    String bId;
    String res = null;
    EditText notes;
    Button save;
    private Button createNote;
    private int position;
    private String type;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.notes_layout);
        createNote = (Button) findViewById(R.id.notes_layout_btn_createNote);
        Bundle bundle = this.getIntent().getExtras();
        position = bundle.getInt("position");
        type = bundle.getString("type");

        //
        if (type.equals("LISTINGS")) {
            Listings it = ListingsFragment.myListings.getListings().get(
                    position);
            bId = it.getBID();
            notes = (EditText) findViewById(R.id.notes);
        }
        //
        if (type.equals("SHARED")) {
            Listings it = SharedFragment.myShared.getListings().get(position);
            bId = it.getBID();
            notes = (EditText) findViewById(R.id.notes);
        }
        GetNotes getNotes = new GetNotes();
        try {
            NotesList copy = new NotesList();

            getNotes.execute(key, bId).get();
            for (int j = 0; j < myNotes.getNotes().size(); j++) {
                Notes note = myNotes.getNotes().get(j);
                System.out.println("Removed value: " + note.getIsRemoved());
                if (note.getIsRemoved() == null) {
                    copy.getNotes().add(note);
                }
            }
            NotesAdapter adapter = new NotesAdapter(this, R.layout.note_row,
                    copy.getNotes());
            ListView lv = (ListView) findViewById(R.id.notes_layout_lv_notesList);
            lv.setAdapter(adapter);
        } catch (Exception e) {
        }
        createNote.setOnClickListener(this);

    }

    private class GetNotes extends AsyncTask<String, String, NotesList> {

        @Override
        protected NotesList doInBackground(String... things) {

            ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
            postParameters.add(new BasicNameValuePair("key", things[0]));
            postParameters.add(new BasicNameValuePair("bId", things[1]));

            // String valid = "1";
            String response = null;

            try {
                response = CustomHttpClient.executeHttpPost(
                        "http://propclip.dev/mobile.php", postParameters);
                res = response.toString();
                // System.out.println("This is the response " + res);
                // res = res.trim();
                // res= res.replaceAll("\\s+","");
                // error.setText(res);
                // System.out.println(res);
                myNotes = gson.fromJson(res, NotesList.class);
                // System.out.println(res);
            } catch (Exception e) {
                res = e.toString();
            }
            return myNotes;
        }

        @Override
        protected void onPostExecute(NotesList res) {
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.notes_layout_btn_createNote:
            ProfileDataSource datasource = new ProfileDataSource(this);
            datasource.open();
            PropClipGlobal pcg = datasource.getUserIdenity();
            Intent intent = new Intent(this, NewNoteActivity.class);
            intent.putExtra("bId", bId);
            intent.putExtra("uId", pcg.getUID());
            intent.putExtra("username", pcg.getEm());
            intent.putExtra("position", position);
            intent.putExtra("type", type);
            startActivity(intent);
        }
    }
}
公共类NotesActivity扩展了活动实现OnClickListener{
String key=“NOTES”;
String key2=“更新注释”;
Gson Gson=新的Gson();
//Notes myNotes=新Notes();
NotesList myNotes=新建NotesList();
串标;
字符串res=null;
编辑文本注释;
按钮保存;
私人按钮创建注释;
私人职位;
私有字符串类型;
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.notes\u布局);
createNote=(按钮)findViewById(R.id.notes\u布局\u btn\u createNote);
Bundle Bundle=this.getIntent().getExtras();
位置=bundle.getInt(“位置”);
类型=bundle.getString(“类型”);
//
if(type.equals(“列表”)){
Listings it=ListingsFragment.myListings.getListings().get(
职位);
bId=it.getBID();
notes=(EditText)findViewById(R.id.notes);
}
//
if(type.equals(“共享”)){
Listings it=SharedFragment.myShared.getListings().get(位置);
bId=it.getBID();
notes=(EditText)findViewById(R.id.notes);
}
GetNotes GetNotes=newgetnotes();
试一试{
NotesList copy=新建NotesList();
执行(key,bId).get();
对于(int j=0;j
我的自定义适配器

public class NotesAdapter extends ArrayAdapter<Notes> {
    List<Notes> notes;
    Context context;

    public NotesAdapter(Context context, int resource, List<Notes> notes) {
        super(context, resource, notes);
        this.notes = notes;
        this.context = context;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        if (v == null) {
            LayoutInflater vi;
            vi = LayoutInflater.from(getContext());
            v = vi.inflate(R.layout.note_row, null);
        }

        Notes note = notes.get(position);
        ImageView icon = (ImageView) v.findViewById(R.id.note_row_icon);
        TextView name = (TextView) v.findViewById(R.id.note_row_name);
        TextView message = (TextView) v.findViewById(R.id.note_row_message);
        TextView date = (TextView) v.findViewById(R.id.note_row_date);
        String input = note.getNoteDate();
        SimpleDateFormat inputDf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat outputDf = new SimpleDateFormat("dd, yyyy");
        SimpleDateFormat monthFormat = new SimpleDateFormat("MM");
        Date myDate = null;
        try {
            myDate = inputDf.parse(input);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        String month = monthFormat.format(myDate);
        date.setText(getMonth(Integer.parseInt(month)) + " "
                + outputDf.format(myDate));
        message.setText(note.getNote());
        name.setText(note.getFirstName() + " " + note.getLastName());
        // System.out.println(p.getFileData());
        byte[] imageAsBytes = Base64.decode(note.getFileData().getBytes(),
                position);
        icon.setImageBitmap(BitmapFactory.decodeByteArray(imageAsBytes, 0,
                imageAsBytes.length));
        System.out.println(note.getFileData());
        return v;
    }

    public String getMonth(int month) {
        return new DateFormatSymbols().getMonths()[month - 1];
    }
}
公共类NotesAdapter扩展了ArrayAdapter{
清单说明;
语境;
公共notesdapter(上下文、int资源、列表注释){
超级(上下文、资源、注释);
this.notes=注释;
this.context=上下文;
}
@凌驾
公共视图getView(int位置、视图转换视图、视图组父视图){
视图v=转换视图;
如果(v==null){
拉平机vi;
vi=LayoutInflater.from(getContext());
v=vi.充气(右布局注释,空);
}
Notes note=Notes.get(位置);
ImageView图标=(ImageView)v.findViewById(R.id.note\u row\u图标);
TextView名称=(TextView)v.findViewById(R.id.note\u行名称);
TextView消息=(TextView)v.findViewById(R.id.note\u row\u消息);
TextView日期=(TextView)v.findViewById(R.id.note\u row\u date);
字符串输入=note.getNoteDate();
SimpleDataFormat inputDf=新SimpleDataFormat(“yyyy-MM-dd HH:MM:ss”);
SimpleDataFormat outputDf=新的SimpleDataFormat(“dd,yyyy”);
SimpleDateFormat monthFormat=新S
public class NewNoteActivity extends Activity implements OnClickListener {
    private String uId;
    private String bId;
    private String username;
    private String response;
    private String key = "UPDATE_NOTES";
    private Button submit;
    private EditText note;
    private int position;
    private String type;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_new_note);
        submit = (Button) findViewById(R.id.activity_new_note_btn_submit);
        note = (EditText) findViewById(R.id.activity_new_note_et_note);
        Intent intent = getIntent();
        bId = intent.getStringExtra("bId");
        uId = intent.getStringExtra("uId");
        username = intent.getStringExtra("username");
        position = intent.getIntExtra("position", 0);
        type = intent.getStringExtra("type");
        submit.setOnClickListener(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.new_note, menu);
        return true;
    }

    private class UpdateNotes extends AsyncTask<String, String, String> {

        @Override
        protected String doInBackground(String... values) {

            ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
            postParameters.add(new BasicNameValuePair("key", values[0]));
            postParameters.add(new BasicNameValuePair("bId", values[1]));
            postParameters.add(new BasicNameValuePair("uId", values[2]));
            postParameters.add(new BasicNameValuePair("username", values[3]));
            postParameters.add(new BasicNameValuePair("note", values[4]));

            String response = null;

            try {
                response = CustomHttpClient.executeHttpPost(
                        "http://propclip.dev/mobile.php", postParameters);
                response = response.toString();

            } catch (Exception e) {
                response = e.toString();
            }
            return null;
        }

        @Override
        protected void onPostExecute(String response) {
            Intent intent = new Intent(getApplicationContext(),
                    NotesActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.putExtra("position", position);
            intent.putExtra("type", type);
            startActivity(intent);
            Toast toast = Toast.makeText(getApplicationContext(),"Added note!", Toast.LENGTH_LONG);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
        }
    }

    @Override
    public void onClick(View v) {
        String noteMessage = note.getText().toString();
        UpdateNotes updateNotes = new UpdateNotes();
        updateNotes.execute(key, bId, uId, username, noteMessage);
    }
}