android layout-land和layout-port问题

时间:2012-09-09 15:35:53

标签: android android-layout orientation

我的布局文件夹包含纵向布局和布局 - 土地文件夹以及横向布局 现在这样的情况:我开始app纵向orientatin - 好吧,正确的布局,改变方向 - 好的,景观布局,再次改变方向 - 和..方向改变但布局是风景..
它是什么?

EDITED


代码:

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();
    }

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

1 个答案:

答案 0 :(得分:3)

此活动的清单元素中是否有任何特殊标记,例如configChanges可能会使其选择资源的方式复杂化?

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

layout/
    //Your portrait (default) layout
layout-land/
    //Your landscape layout overrides