您的位置:首页 > 其它

开发笔记

2015-11-28 15:17 330 查看
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">本笔记主要是记录平时开发时遇到的细节方面的问题或者常用的小功能的记录。</span>

1.动态设置布局中ImageView的图片

public void initTitleBar() {
ibTab1Left.setBackgroundResource(R.drawable.money_set);
ibTab1Right.setBackgroundResource(R.drawable.money_share);
tvTitle.setText(R.string.tab1_driving_account_details);

//        ibTab1Left.getResources().getDrawable(R.drawable.money_set);
//        ibTab1Right.getResources().getDrawable(R.drawable.money_share);

//        ibTab1Left.setImageDrawable(getResources().getDrawable(R.drawable.money_set));
//        ibTab1Right.setImageDrawable(getResources().getDrawable(R.drawable.money_share));
}


2.利用List动态设置TextView文本信息

此处用了Annotations注解框架
@ViewsById({ R.id.text1, R.id.text2 })
List<TextView> list;
@AfterViews
public void setTextView() {
for (TextView textele : list) {
list.get(0).setText("hello");
list.get(1).setText("world");
}
}


3.Eclipse/Android Studio 快捷键

Ctrl+Shift+X→小写转大写
Ctrl+Shift+Y→大写转小写


4.BaseAdapter使用步骤

1.创建一个MyAdapter继承BaseAdapter
2.实现BaseAdapter里面的方法
3.创建构造方法,eg.(Context context,List<String> list)
4.修改getCount()返回值为list.size
5.修改getItem()方法返回值为list.get(position)
6.修改getItemId返回值为position
7重写getView()方法


5.double,int转化为String类型

String.valueOf(int)
String.valueOf(double)


6.调用系统相机注意点

1.启动方式
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
2.注册Camera功能(其他应用请求系统相机时会弹出选择对话框),写在AndroidManifest.xml中

<intent-filter>
<action android:name="android.media.action.IMAGE_CAPTURE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>


7.页面跳转动画效果

从左到右滑出
push_left_in:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="100%p" android:toXDelta="0"
android:duration="200" />
</set>


push_left_out:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0" android:toXDelta="-100%p"
android:duration="200" />
</set>


从右到左滑出
push_right_in:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="0" android:toXDelta="100%p"
android:duration="200" />
</set>


push_right_out:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromXDelta="-100%p" android:toXDelta="0"
android:duration="200" />
</set>


8.在Fragment里面设定点击事件

事件不要在onCreateView里面加,需要的话再onActivityCreate里边加,使用方法和在activity里边是一样的。

@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
initEvents();
}


9.在Fragment中用BaseAdapter里面getView()方法怎么用

@Override
public View getView(int position, View arg1, ViewGroup parent) {
View view =   LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_layout, parent, false);
<span style="white-space:pre">	</span>//getLayoutInflater().inflate(R.layout.item_layout, null);
ImageView touxiang = (ImageView) view.findViewById(R.id.iv_touxiang);
TextView neirong = (TextView) view.findViewById(R.id.tv_neirong);
touxiang.setImageResource(imageids[position]);
neirong.setText(descStrings[position]);
return view;
}

10.Android TextView文字加下划线

tvForgetPassword.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  开发 整理 注意点