DataPicker看起来像旧的设计新的API,以及 [英] DataPicker looks like old design on new API's as well

查看:288
本文介绍了DataPicker看起来像旧的设计新的API,以及的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,问题很简单:

我在我的应用程序集成了一个 DataPicker 。 还不如 DialogDataPicker 但作为一个视图组件(更多precisely一个查看 A <$ C $内C>片段的动态显示和删除了的FrameLayout 包含在我的主 FragmentActiviy 布局)。

I have integrated a DataPicker in my application. Not as a DialogDataPicker but as a View component (more precisely a View inside of a Fragment that is dynamically shown and removed from a FrameLayout contained in my main FragmentActiviy layout.).

现在我的问题是,这DataPicker看起来是这样的:

now my problem is that this DataPicker looks like this:

和不喜欢这样的:

甚至当我瞄准更高的API,我尝试设置我的民SDK为16或17,以及,但它没有做任何帮助的。

even when I target the higher API's, I tried setting my Min SDK to 16 or 17 as well but it didn't do any help either.

有些人知道为什么会发生?我该怎么让数据采集器的新面貌? preferably老版本的Andr​​oid呢?

Some one know why it happens? and how can I show the new look of the data picker? preferably on old versions of Android as well?

任何帮助将是AP preciated。

Any help would be appreciated.

感谢。

编辑: code:

DataPickerFragment XML:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="6.5dp"
android:paddingTop="6dp"
android:paddingRight="8.5dp"
android:paddingBottom="8.5dp"
android:background="@drawable/date_picker_background">

<DatePicker
    android:id="@+id/datePicker"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp"
    android:paddingBottom="40dp" />

<LinearLayout 
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <Button
        android:id="@+id/bCancel"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_weight="1.0"
        android:onClick="buttonCanceDatePickerOnclick"
        android:text="@string/cancel" />

    <Button
        android:id="@+id/bSave"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_weight="1.0"
        android:onClick="buttonSaveDatePickerOnclick"
        android:text="@string/save" />

 </LinearLayout>

DataPickerFramgnet类:

public class DatePickerFragment extends Fragment 
{
private Button bSave, bCancel;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.date_picker_fragment_layout,
            container, false);
    return rootView;
}
}

更新:

Manifast文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.emildesign.sgreportmanager"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="13"
    android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<!--  Crittercism  -->
<uses-permission android:name="android.permission.READ_LOGS"/>
<uses-permission android:name="android.permission.GET_TASKS"/>

<application
    android:allowBackup="true"
    android:name="com.emildesign.sgreportmanager.SGRaportManagerAppObj"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
    <activity
        android:name="com.emildesign.sgreportmanager.activities.LoginScrActivity"
        android:screenOrientation="landscape" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
     <activity
        android:name="com.emildesign.sgreportmanager.activities.ReportsTableActivity"
        android:screenOrientation="landscape" >
    </activity>
    <activity
        android:name="com.emildesign.sgreportmanager.activities.ParametersActivity"
        android:screenOrientation="landscape" >
    </activity>
    <activity android:name="com.crittercism.NotificationActivity"/>  
</application>

还有,我发现在我的问题是,我设置:

well I found where my problem was, I set:

android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" 

让我的应用程序全屏和这个应用的老式数据选择器将其更改为:

to make my application full screen and this applied the old style of the data picker changing it to:

android:theme="@android:style/Theme.Holo.Light.NoActionBar.Fullscreen"

创建以下DataPicker:

Creates the following DataPicker:

这是更好,然后才但这仍然不是我要找的结果。

It's better then before but this is still not the result I'm looking for.

推荐答案

设置你的安卓targetSdkVersion 是11或更高。 下面是一个示例应用程序展示了这一

Set your android:targetSdkVersion to be 11 or higher. Here is a sample application demonstrating this.

更新

首先,你原来的的DatePicker 截图是从一个黑暗的主题(例如, Theme.Holo ),而你第二个屏幕是由轻主题(例如, Theme.Holo.Light )。

First, your original DatePicker screenshot is from a dark theme (e.g., Theme.Holo), whereas your second screenshot is from a light theme (e.g., Theme.Holo.Light).

二,的DatePicker 文档具有以下开头一段:

Second, the DatePicker documentation has the following opening paragraph:

这类是窗口小部件中选择一个日期。该日期可通过年,月,日纺纱或CalendarView选择。该集纺纱和日历视图的自动同步。客户机可以自定义是否仅微调器,或只在日历视图或两者被显示。另外从最小和最大的日期可以追溯到选择可以自定义。

This class is a widget for selecting a date. The date can be selected by a year, month, and day spinners or a CalendarView. The set of spinners and the calendar view are automatically synchronized. The client can customize whether only the spinners, or only the calendar view, or both to be displayed. Also the minimal and maximal date from which dates to be selected can be customized.

您可以得到通过摆脱 CalendarView 的机器人:calendarViewShown (或 setCalendarViewShown( ))。当你尝试,你会发现,你的一年微调将出现一次 CalendarView 走了。

You can get rid of the CalendarView via android:calendarViewShown (or setCalendarViewShown()). When you try that, you will find that your year spinner will appear once the CalendarView is gone.

这篇关于DataPicker看起来像旧的设计新的API,以及的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆