2

我有用于纵向布局的布局文件夹和用于横向布局的 layout-land 文件夹。
现在这种情况:我以纵向方向启动应用程序 - 好的,正确的布局,改变方向 - 好的,横向布局,再次改变方向 - 并且..方向改变但布局是横向..
这是什么?

编辑:
代码:

private TextView mTxtGoDate;
private TextView mTxtGoBackDate;
private TextView mTxtCityFrom;
private TextView mTxtCityWhere;

private TextView mTxtManCount;
private TextView mTxtChildCount;
private TextView mTxtBabyCount;
private TextView mTxtClass;

private CheckBox mCheckOneWay;
private CheckBox mCheckRange;

private RelativeLayout mLayoutGoBack;

private Button mBtnSearch;

private SearchParams mSearchParams;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_new_search);

    mSearchParams = new SearchParams();

    mTxtGoDate = (TextView) findViewById(R.id.txt_go_date);
    mTxtGoDate.setOnClickListener(this);
    getDateGo();
    mTxtGoDate.setText(mSearchParams.getGoDate().getDateAsString());

    mTxtGoBackDate = (TextView) findViewById(R.id.txt_go_back_date);
    mTxtGoBackDate.setOnClickListener(this);
    getDateGoBack();
    mTxtGoBackDate.setText(mSearchParams.getGoBackDate().getDateAsString());

    mTxtCityWhere = (TextView) findViewById(R.id.txt_where_city);
    mTxtCityWhere.setOnClickListener(this);
    mTxtCityFrom = (TextView) findViewById(R.id.txt_from_city);
    mTxtCityFrom.setOnClickListener(this);

    mCheckOneWay = (CheckBox) findViewById(R.id.check_one_way);
    mCheckOneWay.setOnCheckedChangeListener(this);
    mCheckRange = (CheckBox) findViewById(R.id.check_correct);

    mLayoutGoBack = (RelativeLayout) findViewById(R.id.layout_go_back);
    ((LinearLayout) findViewById(R.id.params_layout)).setOnClickListener(this);
    mTxtManCount = (TextView) findViewById(R.id.param_man);
    mTxtChildCount = (TextView) findViewById(R.id.param_child);
    mTxtBabyCount = (TextView) findViewById(R.id.param_baby);
    mTxtClass = (TextView) findViewById(R.id.param_class);

    mBtnSearch = (Button) findViewById(R.id.btn_search_flightes);
    mBtnSearch.setOnClickListener(this);

    CitiesDataSource dbCities = new CitiesDataSource(this);
    dbCities.open();
        City from = dbCities.getLatestCity(true);
        City where = dbCities.getLatestCity(false);
        if (from != null) {
            mTxtCityFrom.setText(from.getName());
            mSearchParams.setFrom(from);
        }
        if (where != null) {
            mTxtCityWhere.setText(where.getName());
            mSearchParams.setWhere(where);
        }
    dbCities.close();
}

@Override
public void onResume() {
    super.onResume(false);
}

超类中的 onResume:

protected void onResume(boolean flag) {
        super.onResume();
    }

其他代码与我的问题无关。谢谢

4

1 回答 1

3

您在此 Activity 的清单元素中是否有任何特殊标签,例如configChanges这可能会使它选择资源的方式复杂化?

您也可以尝试将纵向布局放在默认目录中,并且只有一个合格的横向布局目录,即

layout/
    //Your portrait (default) layout
layout-land/
    //Your landscape layout overrides
于 2012-10-28T03:24:24.047 回答