1. 样式与主题
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyRedTheme" parent="android:Theme.Light">
<item name="android:textAppearance">@style/MyRedTextAppearance</item>
</style>
<style name="MyRedTextAppearance" parent="@android:style/TextAppearance">
<item name="android:textColor">#F00</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is red, isn't it?"
/>
</LinearLayout>
2.
public class RedTextView extends TextView{
public RedTextView(Context context, AttributeSet attrs) {
super(context, attrs);
setTextColor(Color.RED);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<org.example.RedTextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is red, isn't it?"
/>
</LinearLayout>
Xcode代码提示生成源代码程序块默认格式如下,注意左花括号的位置:
if ( condition ) { do ... }
因为以前的使用习惯,我想让自动生成的左右花括号都单独成行,变成下面的样子:
if ( condition ) { do ... }
在Terminal里面,运行下面命令,然后重启Xcode:
defaults write com.apple.Xcode XCCodeSenseFormattingOptions -dict BlockSeparator "\n"这个命令修改了~/Library/Preferences/com.apple.Xcode.plist,这是Xcode的配置文件
import java.util.HashMap; import java.util.List; import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.SimpleAdapter; public class SpecialAdapter extends SimpleAdapter { private int[] colors = new int[] { 0x30FF0000, 0x300000FF }; public SpecialAdapter(Context context, List<HashMap<String, String>> items, int resource, String[] from, int[] to) { super(context, items, resource, from, to); } @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); int colorPos = position % colors.length; view.setBackgroundColor(colors[colorPos]); return view; } }
SpecialAdapter adapter = new SpecialAdapter(this,fillMaps,R.layout.grid_item,from,to); ...