انجمن سایت کلیدستان


رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
ساخت جستجو

ساخت جستجو

#1
سلام خدمت آدمین بقیه اساتید من این لیست اکتیویتی رو ساختم اما تو ساخت قسمت جستجو اشکال دارم یعنی نمیتونم آداپتر رو فیلتر کنم.این کدشه ممنون میشم کمک کنید. این که کل اکتیویته
کد پی‌اچ‌پی:
public ListView lv;
public 
Globalsd global = new Globalsd();
public 
int Subjects_total_number;
public 
String[] Subjects;
SharedPreferences full;
EditText search;

public class 
MyAdapter extends ArrayAdapter<String> {

    public 
MyAdapter(Context contextint resourceint textViewResourceId,
            
String[] strings) {
        
super(contextresourcetextViewResourceIdstrings);
        
// TODO Auto-generated constructor stub
    
}

    @
Override
    
public View getView(int positionView convertViewViewGroup parent) {
        
LayoutInflater inflater = (LayoutInflatergetSystemService(Context.LAYOUT_INFLATER_SERVICE);
        
View row inflater.inflate(R.layout.list_item_subjectsd1parent,
                
false);
        
String[] items Subjects;

        
TextView tv = (TextViewrow.findViewById(R.id.textView1);
        
tv.setText(items[position]);
        
Animation animation AnimationUtils.loadAnimation(getContext(),
                
R.anim.slide_in_right);
        
row.startAnimation(animation);

        return 
row;
    }
}
@
Override
protected void onCreate(Bundle savedInstanceState) {
    
super.onCreate(savedInstanceState);
    
screnpref();
    
setContentView(R.layout.a_drog1);
    
search = (EditTextfindViewById(R.id.edtsearchd1);
    
Subjects_total_number = global.Subjects_total_numberd;
    
Subjects = new String[Subjects_total_number];
    for (
int x 1Subjects_total_number 11) {
        
String this_subject "subject_" String.valueOf(x);
        
int resID getResources().getIdentifier(this_subject"string",
                
getPackageName());
        
Subjects[1] = getResources().getString(resID);
    }

    
setListAdapter(new MyAdapter(thisandroid.R.layout.simple_list_item_1,
            
R.id.textView1Subjects));

    
lv getListView();
    
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @
Override
        
public void onItemClick(AdapterView<?> parent, final View view,
                int position, long id) {
            Intent i = new Intent(getApplicationContext(), Secendd1.class);
            String Subject_number = String.valueOf(position + 1);
            i.putExtra("subject_number", Subject_number);
            startActivity(i);
        }

    });


    search.addTextChangedListener(new TextWatcher() {





        @Override
        public void onTextChanged(CharSequence s, int start, int before,
                int count) {

 [color=#FF0000]        //this line:
         //how i can filter this adapter
         //این قسمت من اشکال دارم[/color]
        ((ArrayAdapter<String>) this.MyAdapter).getFilter().filter(s);

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
            // TODO Auto-generated method stub

        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

        }
    });




 
پاسخ

ساخت جستجو

#2
سلام دوست عزیز من لینک زیر رو به شما پیشنهاد میکنم
http://openandroid.ir/2015/04/%DA%A9%D8%...%85%D9%87/
 
پاسخ
 سپاس شده توسط شماره مجازی امارات ، تلگرام ضد فیلتر 2023


پرش به انجمن:


کاربران در حال بازدید این موضوع: 1 مهمان