position に基づいて、リストビューのテキストビューの背景色を変更する必要があります。位置が 1 の場合にのみ、背景色を赤にする必要があります。それ以外の場合、背景色はありません。これが私のgetviewです。最初の位置では色が赤になりますが、他の位置では、リストビューを上下にスクロールすると背景色が変化します
@Override
public View getView(final int position, View convertView,
ViewGroup parent) {
// TODO Auto-generated method stub
if (convertView == null) {
convertView = getLayoutInflater().inflate(
R.layout.bookmarkslayout, null);
holder = new ViewHolder();
holder.bookMarkImage = (ImageView) convertView
.findViewById(R.id.bookMarkImage);
holder.bookMarkTitle = (TextView) convertView
.findViewById(R.id.bookMarkTitle);
holder.bookMarksLayout = (LinearLayout) convertView
.findViewById(R.id.bookMarksLayout);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
if (getApplicationContext().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
holder.bookMarksLayout.setOrientation(LinearLayout.VERTICAL);
} else {
holder.bookMarksLayout.setOrientation(LinearLayout.HORIZONTAL);
}
holder.bookMarkImage.setBackgroundResource(getResources()
.getIdentifier(albumArray[position], "drawable",
"com.cognizant.vivid"));
// holder.bookMarkTitle.setText(albumArray[position]);
holder.bookMarkTitle.setText(AccountsArray[position]);
if (AccountsArray[position].equalsIgnoreCase("Add Account")) {
holder.bookMarkTitle.setBackgroundColor(Color.RED);
}else{
holder.bookMarkTitle.setBackgroundColor(Color.parseColor("#40808080"));
}
holder.bookMarksLayout.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// player.reset();
if (position == 0) {
player.stop();
player.release();
player = null;
surfaceholder = surfaceView.getHolder();
surfaceholder.addCallback(Player.this);
surfaceholder
.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
player = new MediaPlayer();
player.setDisplay(surfaceholder);
player.setScreenOnWhilePlaying(true);
try {
player.setDataSource(
getApplicationContext(),
Uri.parse("http://brightcove.vo.llnwd.net/e1/uds/pd/1937897674001/1937897674001_1939672863001_Wildlife-TamarinMonkey.mp4"));
// player.setDataSource(
// getApplicationContext(),
// Uri.parse("http://mspss.cognizant.com/vivid/videos/intuit/2intuit.mp4"));
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.setOnPreparedListener(Player.this);
player.prepareAsync();
// player.setOnBufferingUpdateListener(this);
player.setOnCompletionListener(Player.this);
secondaryBookMarksAdapter adapter = new secondaryBookMarksAdapter();
bookMarkListView.setAdapter(adapter);
bookMarkListViewLandscape.setAdapter(adapter);
// VideoTimerHandler videoTimerHandler = new
// VideoTimerHandler();
// videoTimerHandler.playVideoTimer();
// playVideo("http://brightcove.vo.llnwd.net/e1/uds/pd/1937897674001/1937897674001_1939672863001_Wildlife-TamarinMonkey.mp4");
} else {
if (position == 1) {
player.seekTo(115000);
timeline.setProgress(115000);
player.seekTo(30000);
timeline.setProgress(30000);
}
if (position == 2) {
player.seekTo(140000);
timeline.setProgress(140000);
}
if (position == 3) {
player.seekTo(205000);
timeline.setProgress(205000);
}
if (position == 4) {
player.seekTo(270000);
timeline.setProgress(270000);
}
}
}
});
return convertView;
}