Android 未使用自定义列表适配器中的getView()方法

Android 未使用自定义列表适配器中的getView()方法,android,custom-lists,Android,Custom Lists,嗨,我一直在尝试使用自定义列表项布局的自定义列表活动,我迫切需要帮助。我用作列表适配器的自定义适配器类可能是错误的,也可能是正确的,但无论它是什么,都没有使用getView()方法,并且当我将日志放入其中时,它不会显示,我的适配器类如下所示: private class MyAdapter extends ArrayAdapter<String>{ int position1; public MyAdapter(Context context, int resou

嗨,我一直在尝试使用自定义列表项布局的自定义列表活动,我迫切需要帮助。我用作列表适配器的自定义适配器类可能是错误的,也可能是正确的,但无论它是什么,都没有使用getView()方法,并且当我将日志放入其中时,它不会显示,我的适配器类如下所示:

private class MyAdapter extends ArrayAdapter<String>{

    int position1;

    public MyAdapter(Context context, int resource,int pos) {
        super(context, resource);
        position1 = pos;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View row = inflater.inflate(R.layout.privatep_single_list_item, parent, false);
        String[] general_Items = new String[Items.length()] ;
        String[] financial_Items = new String[Items.length()] ; 
        String[] address_Items = new String[Items.length()] ; 
        StringBuilder general_sb = new StringBuilder();
        StringBuilder financial_sb = new StringBuilder();
        StringBuilder address_sb = new StringBuilder();
        if(position1 == 0){
        try{
        for(int i = 0; i < Items.length(); i++){

                general_sb.append(Items.getJSONObject(i).getString("Area").toString());
                general_sb.append(" متر ");
                general_sb.append(Items.getJSONObject(i).getString("Bedrooms").toString());
                general_sb.append(" خواب ");
                general_sb.append(Items.getJSONObject(i).getString("CA").toString());
                general_sb.append(" ساخت ");

                financial_sb.append("متری ");
                financial_sb.append(Items.getJSONObject(i).getString("OPPM").toString());
                financial_sb.append(" تومان");

                address_sb.append(Items.getJSONObject(i).getString("address").toString());

                general_Items[i] = general_sb.toString();
                financial_Items[i] = financial_sb.toString();
                address_Items[i] = address_sb.toString();

        }}
        catch (Exception e){
            Log.e("Fail 3", e.toString());
        }
        } else if (position1 == 1){

            try{
                for(int i = 0; i < Items.length(); i++){

                        general_sb.append(Items.getJSONObject(i).getString("Area").toString());
                        general_sb.append(" متر ");
                        general_sb.append(Items.getJSONObject(i).getString("Bedrooms").toString());
                        general_sb.append(" خواب ");
                        general_sb.append(Items.getJSONObject(i).getString("CA").toString());
                        general_sb.append(" ساخت ");

                        financial_sb.append("کرایه ");
                        financial_sb.append(Items.getJSONObject(i).getString("Rent").toString());
                        financial_sb.append(" /n");
                        financial_sb.append("رهن ");
                        financial_sb.append(Items.getJSONObject(i).getString("PrePayment").toString());

                        address_sb.append(Items.getJSONObject(i).getString("address").toString());

                        general_Items[i] = general_sb.toString();
                        financial_Items[i] = financial_sb.toString();
                        address_Items[i] = address_sb.toString();

                }}
                catch (Exception e){
                    Log.e("Fail 3", e.toString());
                }
        } else if (position1 == 2){
            try{
                for(int i = 0; i < Items.length(); i++){

                        general_sb.append(Items.getJSONObject(i).getString("Area").toString());
                        general_sb.append(" متر ");
                        general_sb.append(Items.getJSONObject(i).getString("Bedrooms").toString());
                        general_sb.append(" خواب ");
                        general_sb.append(Items.getJSONObject(i).getString("CA").toString());
                        general_sb.append(" ساخت ");

                        financial_sb.append("رهن ");
                        financial_sb.append(Items.getJSONObject(i).getString("Price").toString());

                        address_sb.append(Items.getJSONObject(i).getString("address").toString());

                        general_Items[i] = general_sb.toString();
                        financial_Items[i] = financial_sb.toString();
                        address_Items[i] = address_sb.toString();

                }}
                catch (Exception e){
                    Log.e("Fail 3", e.toString());
                }
        }


        TextView general_text = (TextView) row.findViewById(R.id.General_Info);
        TextView financial_text = (TextView) row.findViewById(R.id.Financial_Info);
        TextView address_text = (TextView) row.findViewById(R.id.Address_Info);

        general_text.setText(general_Items[position]);
        financial_text.setText(financial_Items[position]);
        address_text.setText(address_Items[position]);

        return super.getView(position, convertView, parent);
    }
}
私有类MyAdapter扩展了ArrayAdapter{
int位置1;
公共MyAdapter(上下文上下文、int资源、int位置){
超级(上下文、资源);
位置1=位置;
}
@凌驾
公共视图getView(int位置、视图转换视图、视图组父视图){
LayoutFlater充气器=(LayoutFlater)getSystemService(Context.LAYOUT\u充气器\u服务);
视图行=充气机。充气(R.layout.privatepu单列表项,父项,false);
String[]general_Items=新字符串[Items.length()];
String[]financial_Items=新字符串[Items.length()];
String[]address_Items=新字符串[Items.length()];
StringBuilder general_sb=新StringBuilder();
StringBuilder financial_sb=新StringBuilder();
StringBuilder地址_sb=新StringBuilder();
如果(位置1==0){
试一试{
对于(int i=0;i
这是我的适配器的结构

protected void onCreate(Bundle savedInstanceState) {        
    super.onCreate(savedInstanceState);
    setContentView(R.layout.privatep);
    setListAdapter(new MyAdapter(this,android.R.layout.simple_list_item_1,0));

    Spinner spinner = (Spinner) findViewById(R.id.select_Spinner);

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
            R.array.select_Options_personal, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(adapter);

    spinner.setOnItemSelectedListener(this);


}
protectedvoid onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.privatep);
setListAdapter(新的MyAdapter(这个,android.R.layout.simple_list_item_1,0));
微调器微调器=(微调器)findViewById(R.id.select\u微调器);
ArrayAdapter=ArrayAdapter.createFromResource(此,
R.array.select\u Options\u personal,android.R.layout.simple\u spinner\u item);
setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
旋转器。设置适配器(适配器);
spinner.setOnItemSelectedListener(此);
}
我将非常感谢你的评论