smooth-scrolling


Listview SmoothScrollToPosition control with buttons and change item background


I wanna be control listview with buttons, up and down.
When I touch any button listview scrolling up or down.
By the way I wanna see whic one item I catch. Same to TVLİST.
I add photo and easy code.
How can I make this?enter image description here
package com.example.erdogan.seridro;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
ListView liste;
private TextView tx,tx2;
int x=0;
int y=0;
Button up,down;
private String [] ulkeler= {"Sayılar","1","2","3","4","5","6","7", "8", "9", "10","11",
"12", "13","12","11","10","9","8","7","6","5","4","3","2","1"};
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tx = (TextView) findViewById(R.id.textView);
up =(Button)findViewById(R.id.button4);
down =(Button)findViewById(R.id.button3);
liste=(ListView)findViewById(R.id.liste);
ArrayAdapter<String>adaptor= new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,android.R.id.text1,ulkeler);
liste.setAdapter(adaptor);
up.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
liste.smoothScrollToPosition(y);
y=y+1;
liste.getChildAt(4).setBackgroundColor(getResources().getColor(R.color.DarkOrange));
liste.getChildAt(5).setBackgroundColor(getResources().getColor(R.color.FloralWhite));
liste.getChildAt(6).setBackgroundColor(getResources().getColor(R.color.DarkOrange));
if (y>=25){y=24;}
}
});
down.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
y=y-1;
liste.smoothScrollToPosition(y);
liste.getChildAt(4).setBackgroundColor(getResources().getColor(R.color.DarkOrange));
liste.getChildAt(5).setBackgroundColor(getResources().getColor(R.color.FloralWhite));
liste.getChildAt(6).setBackgroundColor(getResources().getColor(R.color.DarkOrange));
if (y<1){y=1;}
}
});
}}
https://i.stack.imgur.com/MsgsJ.jpg

Related Links

Smooth scroll function really slow
Instagram snapwidget stops the smoothscroll
Listview SmoothScrollToPosition control with buttons and change item background
So smooth scrolling like on this website
One Page Scroll add Active class depending on scroll position
Smooth-Div-Scroll and iPad

Categories

HOME
macros
casting
skypedeveloper
watson-iot
crash
coordinates
mingw
aggregation-framework
accordion
aws-devicefarm
summernote
coccinelle
beaker-notebook
waterfall
sha
nsopenpanel
windows-mobile
meteor-accounts
federated
scene7
flickr
geocomplete
asp.net-webhooks
cocoa-scripting
mockserver
blueimp
ninja-forms
server-side-swift
collation
ape-phylo
head
f#-fake
bootstrap-carousel
taleo
line-endings
text-formatting
import.io
openxava
serialversionuid
enet
dynamic-linking
playframework-1.x
activesupport
ajv
richtext
android-vectordrawable
cc
grib
nsalert
dynatable
zedgraph
lightspeed
breadcrumbs
sqlproj
mongodb-3.3
jigsaw
android-xmlpullparser
django-celery
skbio
nslocalizedstring
markerspiderfier
log4cxx
chunks
backtrace
dojox.grid
unityvs
grunt-contrib-connect
yosemite
dirname
oxygenxml
time-frequency
sigma-grid-control
xps
myrrix
kohana-orm
latex-suite
windows-scheduler
gmail-imap
generator-expression
microsoft-speech-platform
boost.build
correctness
states
certificate-revocation
winrt-async
github-archive
advanceddatagrid
cryptolicensing
cpack
llblgen
fxcopcmd
arraycollection
text-manipulation
subdirectories
google-local-search
silverlight-2.0
glassfish-embedded
hp-trim
unauthorized

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App