Listview行高太大.我设计了行项目.这是ListViewItem Layout axml文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_style"
android:gravity="center_horizontal"
android:minWidth="25px"
android:minHeight="25px">
<TextView
android:text="Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/forecastName"
android:gravity="center_vertical"
android:padding="10px"
android:textColor="@color/black"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是Listview布局
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_style"
android:minWidth="25px"
android:minHeight="25px">
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/forecast"
android:divider="@drawable/separator"
android:dividerHeight="3px" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
当应用程序午餐列表视图项具有一些高度时,它与文本视图大小不匹配.我怎样才能调整行高?
如果我android:textSize="?android:attr/textAppearanceLarge"在我的xml中使用我的应用程序崩溃.我不想给出硬编码文本大小,因为我必须为不同的屏幕尺寸创建create xml,或者我必须在运行时管理文本大小.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/title"
android:textSize="?android:attr/textAppearanceLarge" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/saveOnDialog"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/save"
style="?android:attr/buttonBarButtonStyle"
android:textSize="?android:attr/textAppearanceLarge" />
<Button
android:id="@+id/cancelOnDialog"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="@string/cancel"
style="?android:attr/buttonBarButtonStyle"
android:textSize="?android:attr/textAppearanceLarge" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是Log.e输出 -
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.view.LayoutInflater.createView(LayoutInflater.java:620)
06-26 11:46:27.439: E/AndroidRuntime(1731): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
06-26 11:46:27.439: E/AndroidRuntime(1731): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
06-26 11:46:27.439: E/AndroidRuntime(1731): …Run Code Online (Sandbox Code Playgroud) 我想设置listview以显示所有项目而不滚动.
以下是我的布局:
<LinearLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/tv1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:textColor="@android:color/black"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
<TextView
android:id="@+id/tv2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Large Text"
android:textColor="@android:color/black"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
linearlayout属于scrollview.
所以我想设置列表视图所有项目并按父项滚动滚动.
我该怎么做?
我想知道Facebook目前使用哪些组件用于带有图标+线的标签.
截图:

目前我有一个ViewPager和一个FragmentPagerAdapter.但我想知道他们是否正在使用标签的自定义组件.
public static Bitmap getImage(String address) throws Exception {
Bitmap imgmap = null;
InputStream is = null;
URL url = new URL(address);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
try {
conn.setRequestMethod("GET"); >>> here was been excuted,but go to finally block
conn.setConnectTimeout(5000);
is = conn.getInputStream();
byte[] imgbytes = StreamTool.getBytes(is);
imgmap = BitmapFactory.decodeByteArray(imgbytes, 0, imgbytes.length);
} finally {
if (is != null) {
is.close();
}
if (conn != null) {
conn.disconnect();
}
}
return imgmap;
}
Run Code Online (Sandbox Code Playgroud)
在conn.setRequestMethod("GET")被解雇之前,Thorw异常连接已经建立.谁能给我一个解决方案
我的项目中有一个异步任务,如下所示.
@SuppressLint("NewApi")
private void callTask() {
new Task() {
@Override
protected void doInBackground(String... params) {
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
string1,string2 );
}
Run Code Online (Sandbox Code Playgroud)
我在for循环中调用这个callTask()方法10次.
我的任务平行执行,工作正常.我想在一个时间点停止所有任务.我怎样才能做到这一点?
我试图找到一种方法,可以SSID在Android设备上获取记住的网络列表。
我看到一些线程在问类似的问题。但是,我发现的几个问题试图获取已知的网络密码SSIDS,而不是,密码的答案是:
1)如果没有root,您将无法获得它们,并且
2)根据设备,它们存储在不同的位置。
有什么方法可以让我做到这一点?
您好我是android中的新手我试图从EditText获取整数值,但是当我将字符串解析为Integer时,我得到了NumberFormatException.请帮我解决这个错误.提前致谢.
计划是:
int day,month,year;
EditText expense,ammount;
String[] exp=new String[10];
int[] amt=new int[10];
int count=0;
/** Called when the activity is first created. */
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Calendar cal=Calendar.getInstance();
day=cal.get(Calendar.DAY_OF_MONTH);
month=cal.get(Calendar.MONTH)+1;
year=cal.get(Calendar.YEAR);
final TextView txtdate=(TextView)findViewById(R.id.txtdate);
expense=(EditText)findViewById(R.id.exp);
ammount=(EditText)findViewById(R.id.amnt);
final Button add=(Button)findViewById(R.id.btnadd);
final Button cancel=(Button)findViewById(R.id.btncancel);
final Button done=(Button)findViewById(R.id.btndone);
txtdate.setText(day+"/"+month+"/"+year);
add.setOnClickListener(new OnClickListener() {
public void onClick(final View v) {
getval();
}
});
cancel.setOnClickListener(new OnClickListener() {
public void onClick(final View v) {
clean();
}
});
done.setOnClickListener(new OnClickListener() { …Run Code Online (Sandbox Code Playgroud) 如果我添加的项目多于容量中指定的项目,请告诉我HashMap中旧项目的内容是什么?例如:
HashMap<String, Bitmap> hashmap= new HashMap<String, Bitmap>(5);
Run Code Online (Sandbox Code Playgroud)
我将容量设置为5.但如果我将10个项目添加到此HashMap,前5个项目和位图将会是什么?