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
repository
youtube-api
ssms
jenkins-pipeline
crm
app-store
ms-access-2010
multipartform-data
gnuradio
promotions
oms
mongoimport
decoding
guidewire
eclipse-orion
game-engine
owncloud
javaagents
smali
uipath
gsuite
chartist.js
datanucleus
android-cursorloader
smart-device
andengine
overflow
key-bindings
jcr
unity3d-5
offset
dropdownbox
android-geofence
android-databinding
oracle-bpm-suite
client-server
ng-lightning
qt-quick
django-cors-headers
openxava
nservicebus6
seyren
disassembly
wicketstuff
acceleo
catalyst
msiexec
fileopendialog
distcc
mavlink
rowname
cosign-api
vga
falcon
vitamio
window.location
ideavim
std
dynamics-nav
commercetools
avrcp
eggplant
euro
photogrammetry
jad
cl.exe
conkeror
dojox.grid
jsonschema2pojo
msdropdown
class-library
windows-phone-store
mdp
netbeans-plugins
ekevent
objectdatasource
azure-pack
extensibility
spawn
invalidoperationexception
junit-rule
derived-class
optimistic-concurrency
motorola-droid
code-organization
overlays
llblgen
nscharacterset
uccapi
file-storage
manuals
urlscan

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