listview 자바 부분입니다
public class campus extends Activity implements AdapterView.OnItemClickListener{
private String[] mStrings = {
"본관","교수회관","정보문화관","식품영양관","유아교육관","조형관" };
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.listmain);
ListView list = (ListView) findViewById(R.id.list);
list.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, mStrings));
list.setOnItemClickListener(this);
.................
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// TODO Auto-generated method stub
//Toast.makeText(this,String.valueOf(position),Toast.LENGTH_LONG).show();
Intent i = new Intent();
for(int j=0;j<mStrings.length;j++){
if(position==j){
i.setClass(this,List_map_7.class);
i.putExtra("number", mStrings[j]);
startActivity(i);
}
}
}
}
listview를 이렇게 작성하고 listmain.xml을 이용해서
<ListView
android:cacheColorHint="#00000000"
android:divider="#dcdcdc"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
배경색은 뺐는데요..글씨색은 변경이 안되더라구요ㅠ_ㅠ
row.xml을 사용하라는 말도 있고, item을 사용하라시는 분도 계시는데
어떻게 해야할지 몰라서요! 도무지 감이 안잡히네요...
아시는분 알려주세요ㅠ_ㅠ
셀럭터 하나 만드시고...지정하시면 됩니다..
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_pressed="true"
android:color="#ffffff">
</item>
<item
android:state_focused="true"
android:color="#ffffff">
</item>
<item
android:state_selected="true"
android:color="#ffffff">
</item>
<item android:color="#60625a">
</item>
</selector>
쉽죠잉~?
"android.R.layout.simple_list_item_1"이 리스트 아이텝의 레이아웃 리소스 입니다.
즉 리스트 아이템의 색상 모양을 수정 등을 하려면
레이아웃 xml을 하나 만들어서 수정하시면 될 것으로 보입니다.