我尝试CheckBox
使用RelativeLayout
with TextView
和FrameLayout
(在背景上使用选择器)编写我自己的内容.
我setDuplicateParentStateEnabled(true)
为FrameLayout
它取从父辨认的状态,但为什么做RelativeLayout
辨认的,我不知道.
public class MyCheckbox extends RelativeLayout implements OnClickListener, Checkable
{
private static final int ID_CHECKBOX = -1234411;
private static final int ID_TEXTVIEW = -1234412;
private static final int ID_PARENT = -1234413;
private TextView textView;
private FrameLayout checkBox;
private boolean isChecked;
public MyCheckbox(Context context)
{
this(context, null);
}
public MyCheckbox(Context context, AttributeSet attrs)
{
super(context, attrs);
LayoutParams lp;
setId(ID_PARENT);
setOnClickListener(this);
// checkBox
checkBox = new FrameLayout(context); …
Run Code Online (Sandbox Code Playgroud) 我需要在我的应用中接收来自不同发件人的推送通知.它会起作用吗?
分辨率为 240x320、480x640、1536x1152 的屏幕的纵横比为 0.75,分辨率为 480*800 的屏幕的纵横比为 0.6 等。
我需要为不同的纵横比使用不同的资源。
我可以指定配置文件夹给 Android 按屏幕纵横比拍摄图像吗?
当用户在屏幕上向下移动手指时,我想更改视图高度。
new OnTouchListener() {
float lastY = Float.MIN_VALUE;
@Override
public boolean onTouch(View v, MotionEvent event) {
if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_MOVE) {
if (lastY != Float.MIN_VALUE) {
final float dist = event.getRawY() - lastY;
myView.post(new Runnable() {
@Override
public void run() {
ViewGroup.LayoutParams lp = myView.getLayoutParams();
lp.height += dist;
myView.setLayoutParams(lp);
}
});
view.invalidate();
}
lastY = event.getRawY();
}
if ((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP) {
lastY = Float.MIN_VALUE;
}
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
但是只有当用户停止移动手指时,视图高度才会改变!
发生 ACTION_MOVE 时如何立即更改视图高度?
我试图尽可能动态地向LinearLayout添加视图(取决于屏幕宽度).
我在屏幕上显示LinearLayout之前执行此操作.
我的LinearLayout:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:background="#666"/>
Run Code Online (Sandbox Code Playgroud)
我在LinearLayout中显示的视图:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:background="#999">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/no_photo"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
我添加了布局视图:
int allItems = 50;
int currentItem = 0;
while(currentItem < allItems)
{
FrameLayout view = (FrameLayout) inflater.inflate(R.layout.fl, null);
linearLayout.addView(view);
if (linearLayout.getMeasuredWidth() >= this.getWidth())
{
linearLayout.removeView(view);
break;
}
}
Run Code Online (Sandbox Code Playgroud)
但linearLayout.getMeasuredWidth()和this.getWidth()为0;
我知道,我必须使用View.measure方法计算视图大小才可见,但我不知道它在何处以及如何使用.
我有N分.每个点都有X和Y坐标.
我需要找到这个点的质心X和Y. 你能给我一个算法来完成这个任务吗?
我有点旗帜,其中:
A = 1 (0001)
B = 2 (0010)
C = 4 (0100)
D = 8 (1000)
Run Code Online (Sandbox Code Playgroud)
我想在我的旗帜中设置A和C位:flag = A | C
现在我的旗帜是5(0101).
我需要从flag中删除C位.我怎样才能做到这一点?
如何在Android中更改ProgressDialog样式?我需要改变背景颜色和文字颜色.
我的应用程序中有一个样式,我必须覆盖什么项才能更改进度对话框样式?
我想只使用xml更改样式,无需编码.这是可行的吗?
PS:
我没有进度条吧!我有进度对话框.我想使用样式和主题来改变它的样式,比如我改变了listview,windows背景等的样式.
我需要通过单击视图打开上下文菜单.我已经为上下文菜单注册了视图.
当我使用activity时,我只是调用openContextMenu([view context for context menu]); 但片段没有这种方法.
如何通过片段中的一次单击打开上下文菜单?
我需要在android资源中添加带有"@"的字符串,但是会出错:
没有指定资源类型(在'str1'处,值为'@%s test').
我的字符串是:
<string name="str1" formatted="false">@%s test</string>
Run Code Online (Sandbox Code Playgroud)
我如何编码"@"将其放在字符串资源中?
我在我的服务中使用openfire作为聊天服务器.当对话者启动或停止在聊天中输入消息时,我需要通知用户.
我添加自定义消息类型notification_chat并发送带有或没有正文的附加信息:
用户开始输入时:
<message id="SD4Vy-8" to="682@server.com" type="notification_chat"><composing xmlns="http://jabber.org/protocol/chatstates"/></message>
Run Code Online (Sandbox Code Playgroud)
当用户停止输入时:
<message id="SD4Vy-9" to="682@server.com" type="notification_chat"><paused xmlns="http://jabber.org/protocol/chatstates"/></message>
Run Code Online (Sandbox Code Playgroud)
但发送此包后openfire关闭连接!尽管此消息已发送给收件人,但我可以按类型和附加信息处理它.
为什么openfire会踢我这种情况?