可展开的Listview SetIndicatorBounds在我的项目代码中不起作用.
这是我的布局:
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|center_vertical"
android:weightSum="1.0"
>
<ExpandableListView
android:id="@+id/custom_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:dividerHeight="1dp"
android:layout_weight="1"
android:paddingBottom="0dp"
android:divider="#b5b5b5"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
lv1 = (ExpandableListView) findViewById(R.id.custom_list);
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int width = metrics.widthPixels;
lv1.setIndicatorBounds(width - GetPixelFromDips(50), width - GetPixelFromDips(10));
public int GetPixelFromDips(float pixels) {
// Get the screen's density scale
final float scale = getResources().getDisplayMetrics().density;
// Convert the dps to pixels, based on density scale
return (int) (pixels * scale + 0.5f);
}
Run Code Online (Sandbox Code Playgroud)
我的Moto G kitkat设备宽度为720.但是setIndicatorBounds似乎没有在我的Kitkat设备中解决.
任何帮助将不胜感激.
谢谢,
Android - 如何检查另一个逗号分隔字符串中是否存在字符串值.
String all_vals = "617,618,456,1,234,5,5678,225";
String check_val= "456";
Run Code Online (Sandbox Code Playgroud)
怎么检查,
if (all_vals contains check_val) {
}
Run Code Online (Sandbox Code Playgroud) 这是我的字符串,以逗号(,)分隔
$myStr = "One, Two,Three, Four , Five ,Six "
我能够成功爆炸 {assign var="options" value=","|explode:$myStr}
但是我也想在输出每个字符串的开头或结尾删除空格。换句话说:我正在寻找一个SMARTY函数,它等同于PHP的内置trim($mystr)函数。PHP trim将删除开头和结尾的空格(如果存在),否则返回实际的字符串。
{section name=myname loop=$options}
{$options[myname]}
{/section}
Run Code Online (Sandbox Code Playgroud)
上面的代码将输出:
Run Code Online (Sandbox Code Playgroud)One Two Three [whitespace]Four[whitespace] [whitespace]Five[whitespace] Six[whitespace]
如何修剪空格?
如何检查PHP或JavaScript以显示给定的数字是EVEN还是ODD 而不使用条件运算符或控制结构(即没有if,for,foreach,do-while等)?
例如,如果我的输入为20,则系统应输出"EVEN",输入21输出应为"ODD".同样适用于任何数字.
任何帮助将不胜感激.