根据这里的问题,
'tools'命名空间引用(xmlns:tools ="http://schemas.android.com/tools")最近已经开始出现在我的布局中,我想知道更多.原帖只描述了'tools:context'属性,但我也注意到当我为listview指定预览布局项时出现的"tools:listitem"属性的使用,即
<ListView
android:id="@+id/lvCustomer"
tools:listitem="@layout/customer_list_item" >
</ListView>
Run Code Online (Sandbox Code Playgroud)
还有更多元素吗?
是什么让我进入这个'工具'命名空间是因为我希望在eclipse中使用布局设计器时能够拥有'仅预览'文本(即在TextView或EditText中).
目前,我在安排布局时指定'text'或'hint'属性来预览文本...但是我总是要记住从代码中清除预览值.
理想情况下,而不是
<string name="preview_customer_name">Billy Bob's Roadhouse Pub</string>
...
<TextView
android:id="@+id/tvCustomerName"
android:text="@string/preview_customer_name"
</TextView>
Run Code Online (Sandbox Code Playgroud)
有类似的东西:
<TextView
android:id="@+id/tvCustomerName"
tools:previewText="@string/preview_customer_name"
</TextView>
Run Code Online (Sandbox Code Playgroud)
谢谢-
我正在获取具有逻辑顺序的一些数据(进入#temp表)。
当我提取数据时,我想添加一个新的序列/计数器,该序列/计数器仅在其他字段中满足某些条件时才递增。
理想情况是这样的:
DECLARE @counter int = 0;
SELECT Item, Date, Event,
@counter = @counter +
(CASE
WHEN Event = 'Something' THEN 1
ELSE 0
END) AS EVENT_SEQ
INTO #tempTable
FROM MyData
ORDER BY Item, Date
Run Code Online (Sandbox Code Playgroud)
SQL给了我两个错误:
A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
Run Code Online (Sandbox Code Playgroud)
要么
A SELECT INTO statement cannot contain a SELECT statement that assigns values to a variable.
Run Code Online (Sandbox Code Playgroud)
理想的结果
ITEM DATE EVENT EVENT_SEQ
blah 2015-01-01 nothing 1
blah …Run Code Online (Sandbox Code Playgroud) 基本上,我想有一个单一的布局,我可以skin在主题上有所不同.这个网站上的许多示例和条目似乎都围绕这个问题跳了一下,所以我不完全确定它可以做到.或者我只是不明白.
这是概念.
假设我的应用程序与运动相关......应用程序默认为'SportTheme'我想用户也要说他们想要'足球'或'棒球'主题,并且在指定<TextView>元素上,我想要文本(默认为'Sport')更改为'Football'或'Baseball',因为整体主题适用于activity?
在strings.xml中
<string name="label_sport">Sport</string>
<string name="label_football">Football</string>
<string name="label_baseball">Baseball</string>
Run Code Online (Sandbox Code Playgroud)
在activityA.java中 - 这里重要的是为活动设置主题(或者应用程序也很好).
@Override
protected void onCreate(Bundle savedInstanceState)
{
Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState);
this.setContentView(R.layout.layout_a);
switch (user.ThemePreference)
{
case FOOTBALL_THEME:
this.setTheme(R.style.FootballTheme);
break;
case BASEBALL_THEME:
this.setTheme(R.style.BaseballTheme);
break;
default:
this.setTheme(R.style.SportTheme);
break;
}
}
Run Code Online (Sandbox Code Playgroud)
在layout_a.xml中
...
<TextView
android:id="@+id/tvSport"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:text="@string/label_sport"
android:style="@style/SportLabel"></TextView>
Run Code Online (Sandbox Code Playgroud)
我在主题/风格中做什么?像这样的东西?这里重要的是TextView中的文本.我将在整个应用程序中的几个不同活动中使用相同的textView.
<theme name="SportTheme" parent="android:Theme" />
<theme name="FootballTheme" parent="SportTheme">
<item name="android:background">@color/brown</item>
</theme>
<theme name="BaseballTheme" parent="SportTheme">
<item name="android:background">@color/green</item>
</theme>
<theme name="SportTheme.SportLabel">
<item name="android:text">@string/label_sport</item>
</theme>
<theme name="FootballTheme.SportLabel">
<item name="android:text">@string/label_football</item>
<item …Run Code Online (Sandbox Code Playgroud) textview ×2
android ×1
coding-style ×1
namespaces ×1
preview ×1
sql-server ×1
t-sql ×1
text ×1
themes ×1