我正在尝试一个简单的应用程序,当我将值提供给列表视图时,它不显示任何内容。
我的问题快照:
我的Activitymain xml文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<SeekBar
android:id="@+id/seek1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="22dp" />
<ListView
android:id="@+id/list1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/seek1"
android:layout_marginTop="20dp" />
</RelativeLayout>
我的MainActivty.java文件:
package me.mukundmadhav.timestable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SeekBar;
import android.widget.Toast;
import java.util.ArrayList;
import static java.util.Arrays.asList;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SeekBar seekBar = (SeekBar) findViewById(R.id.seek1);
seekBar.setMax(20);
seekBar.setProgress(1);
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
for (int i = 1; i <= 10; ++i)
{
Log.i(Integer.toString(progress),Integer.toString(progress * i));
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
ListView listView = (ListView) findViewById(R.id.list1);
ArrayList<String> table = new ArrayList<String>();
for(int i=1; i<=10;++i){
table.add("a");
}
ArrayAdapter<String> tableAdapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, table);
listView.setAdapter(tableAdapter);
}
}
我尝试评论代码段但仍然无法修复我的问题。
答案 0 :(得分:0)
IF OBJECT_ID('plus1inout', 'P') IS NOT NULL
DROP PROC plus1inout
GO
现在将文件保存为row_item_list.xml。
现在替换
CREATE procedure plus1inout (@arg int, @res int out)
BEGIN ATOMIC
set @res = @arg + 1;
END;
与
Its seems your text is being visible. Its just white in color. To change the text color, if you don't want to change your primary text color, create a new layout which has a text view as follow
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tv"
android:textColor="#000000"
android:padding="5sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
答案 1 :(得分:0)
text.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text"
android:textColor="#000000"
android:padding="5sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
现在在活动文件中:
ArrayAdapter<String> tableAdapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, table);
listView.setAdapter(tableAdapter);
答案 2 :(得分:0)
试试这个......
........
ArrayAdapter<String> tableAdapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, android.R.id.text1, table){
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView textView = (TextView) super.getView(position, convertView, parent);
textView.setTextColor(Color.parseColor("#000000"));
return textView;
}
};
listView.setAdapter(tableAdapter);
.......