Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Viewflow go to view with a button
    text
    copied!<p>I am trying to make a nice horizontal viewgroup with the <a href="https://github.com/pakerfeldt/android-viewflow" rel="nofollow">ViewFlow</a> class. </p> <p>I want to combine it with buttons. For example, when I click button 2 I go to view 2 of the viewgroup. Is that possible? I currently got this:</p> <pre><code>public class HousingActivity extends BaseActivity implements OnClickListener { ViewFlow viewFlow; ListView listView; HousingViewflowAdapter adapter; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.housing_activity); init(); } private void init() { viewFlow = (ViewFlow) findViewById(R.id.viewflow); setOnClickListner(this, this, new int[] { R.id.housing_button1, R.id.housing_button2, R.id.housing_button3, R.id.housing_button4 }); adapter = new HousingViewflowAdapter(this); viewFlow.setAdapter(adapter); viewFlow.setOnViewSwitchListener(new ViewSwitchListener() { @Override public void onSwitched(View view, int position) { } }); listView = (ListView) findViewById(R.id.housing_view1_listview); ArrayList&lt;Community&gt; communityList = new ArrayList&lt;Community&gt;(); // Some dummy data for (int i = 0; i &lt; 10; i++) { communityList.add(new Community("Place " + new Random().nextInt(), new Random().nextInt(), 000000000, "")); } listView.setAdapter(new MainListViewAdapter(this, 0, communityList)); } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // viewFlow.onConfigurationChanged(newConfig); } @Override public void onClick(View v) { super.onClick(v); switch (v.getId()) { case R.id.housing_button1: break; case R.id.housing_button2: break; case R.id.housing_button3: break; case R.id.housing_button4: break; } } } </code></pre> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload