平板开发时,左半部分显示搜索项(其中包括维修记录、保养记录),和两个按钮。右半部分是listfragment显示搜索结果。结果点击搜索按钮时,第一次点击没有任何问题,当切换记录属性后,listfragment没有任何反应,查看LOGCAT时,发现结果已经查找到,但是无法显示到前端,再次切换记录属性时,listframent显示的则是前次结果,本次结果再次存到了后台。哪位遇到过这种情况啊,给点建议。困扰了好一阵子了,试了好多办法都不行,在线等androidlistfragmentrepalce
调试欢乐多
//左界面
public class SearchFragment extends SherlockFragment{
..... //搜索
btnOK.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
String type=getSelectedString();
executeSearch(type);
}
});private void executeSearch(String type) {
ArrayList<String> whereClause=new ArrayList<String>();
if(!TextUtils.isEmpty(edtSerialNumber.getText())){
whereClause.add(QueryMaintainRecord.SERIALNUMBER + " LIKE '" + edtSerialNumber.getText() + "'");
}
if(type=="维修记录"){
VechileMaintainListFragment maintainFragment;
maintainFragment=(VechileMaintainListFragment)getActivity().getSupportFragmentManager().findFragmentByTag(VechileMaintainListFragment.class.getSimpleName());
if(maintainFragment!=null){
getActivity().getSupportFragmentManager().beginTransaction().remove(maintainFragment).commit();
}
maintainFragment=VechileMaintainListFragment.newInstance("");
//Create Bundle
Bundle args=new Bundle();
args.putStringArrayList(VechileMaintainListFragment.KEY_MAINTAIN_WHERE, whereClause);
maintainFragment.setArguments(args);
FragmentTransaction transaction=getActivity().getSupportFragmentManager().beginTransaction();
transaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out,android.R.anim.fade_in,android.R.anim.fade_out);
if(isDualPanel()){
transaction.add(R.id.fragmentDetail, maintainFragment,VechileMaintainListFragment.class.getSimpleName());
}
else{
transaction.replace(R.id.fragmentContent, maintainFragment,VechileMaintainListFragment.class.getSimpleName());
}
transaction.commit();
}
if(type=="保养记录"){
VechileNursingListFragment nursingFragment;
nursingFragment=(VechileNursingListFragment)getActivity().getSupportFragmentManager().findFragmentByTag(VechileNursingListFragment.class.getSimpleName());
if(nursingFragment!=null){
getActivity().getSupportFragmentManager().beginTransaction().remove(nursingFragment).commit();
}
nursingFragment=VechileNursingListFragment.newInstance("");
//Create Bundle
Bundle args=new Bundle();
args.putStringArrayList(VechileNursingListFragment.KEY_NURSE_WHERE, whereClause);
nursingFragment.setArguments(args);
FragmentTransaction transaction=getActivity().getSupportFragmentManager().beginTransaction();
transaction.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out,android.R.anim.fade_in,android.R.anim.fade_out);
if(isDualPanel()){
transaction.add(R.id.fragmentDetail, nursingFragment,VechileNursingListFragment.class.getSimpleName());
}else {
transaction.replace(R.id.fragmentContent, nursingFragment,VechileNursingListFragment.class.getSimpleName());
}
transaction.commit();
}
}
.....
}//SearchActivity layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/theme_background_color"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/fragmentContent"
android:layout_width="400dp"
android:layout_height="match_parent"
android:orientation="horizontal" /> <LinearLayout
android:id="@+id/fragmentDetail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/equipment_margin"
android:background="?attr/shape_background_shadow"
android:padding="@dimen/equipment_padding"
android:orientation="horizontal" />
</LinearLayout>