بروز خطا
[message]
اشتراک در سوال
رای ها
[dataList]
مشکل search
سلام به همه
قسمت search برنامم فقط بین لیست ویو جستجو میکنه و text رو در بر نمیگیره همچنین بعد از جستجو با کلیک روی موارد پیدا شده نمی تونه وارد متن بشه و در لیست ویو متوقف میشه.کدها رو میذارم ممنون میشم اگه کسی راهنمایی کنه.
سورس صفحه search
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.TextView;
public class search extends ListActivity {
private database db;
private String[] Name;
private String[] season;
private String[] cpage;
private String[] page;
private EditText edt_searchbox;
private RadioButton rdo_search_name;
private RadioButton rdo_search_text;
private TextView status;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search);
db = new database(this);
edt_searchbox = (EditText) findViewById(R.id.edt_searchbox);
rdo_search_name = (RadioButton) findViewById(R.id.rdo_search_name);
rdo_search_text = (RadioButton) findViewById(R.id.rdo_search_text);
status = (TextView) findViewById(R.id.txt_status);
refresher(edt_searchbox.getText().toString(), "name");
edt_searchbox.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
if (rdo_search_name.isChecked()) {
refresher(edt_searchbox.getText().toString(), "name");
}
else if (rdo_search_text.isChecked()) {
refresher(edt_searchbox.getText().toString(), "text");
}
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
});
setListAdapter(new AA());
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
Intent intent = new Intent(search.this, storys.class);
intent.putExtra("name", Name[position]);
intent.putExtra("seasone", season[position]);
intent.putExtra("page", cpage[position]);
search.this.startActivity(intent);
}
class AA extends ArrayAdapter<String> {
public AA() {
super(search.this, R.layout.raw_seasone, Name);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater in = getLayoutInflater();
View row = in.inflate(R.layout.raw_seasone, parent, false);
TextView name = (TextView) row.findViewById(R.id.name_season);
TextView r = (TextView) row.findViewById(R.id.teedad_amozesh);
name.setText(season[position] + ": " + Name[position]+page[position]);
name.setTypeface(BookActivity.font);
r.setText("");
return (row);
}
}
private void refresher(String text1, String field) {
db.open();
int save = db.shmaresh_jostojoo(text1, field);
if (edt_searchbox.getText().toString().equals("")) {
save = 0;
status.setText(" لطفا متن مورد نظر خود را وارد کنید ");
} else {
status.setText(" تعداد " + save + " مورد نظر یافت شد");
}
Name = new String[save];
season = new String[save];
cpage = new String[save];
for (int i = 0; i < save; i++) {
Name[i] = db.jostojoo(i, 1, text1, field);
season[i] = db.jostojoo(i, 3, text1, field);
}
setListAdapter(new AA());
db.close();
}
}
کد xml صفحه search
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" android:background="@drawable/bath">
<EditText
android:id="@+id/edt_searchbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:ems="10" />
<RadioGroup
android:id="@+id/radioGroup1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/edt_searchbox"
android:layout_centerHorizontal="true"
android:orientation="horizontal" >
<RadioButton
android:id="@+id/rdo_search_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="بر اساس نام " />
<RadioButton
android:id="@+id/rdo_search_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="بر اساس متن" />
</RadioGroup>
<TextView
android:id="@+id/txt_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/radioGroup1"
android:layout_centerHorizontal="true"
android:text="TextView" android:gravity="center"/>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/txt_status"
android:layout_marginTop="66dp" >
</ListView>
<ir.adad.AdView
android:id="@+id/ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
token="ef6457c39fe64d5eadb2f4f3386d436e"/>
<ir.dgad.AdView
android:id="@+id/adView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
0
0
بچه ها خواهشا یکی راهنمایی کنه (11 سال پیش)
برای این سوال پاسخی وجود ندارد.
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .