import java.util.ArrayList;
import java.util.List;
import com.example.viewpagertest.CircleLayout.OnItemClickListener;
import com.example.viewpagertest.CircleLayout.OnItemSelectedListener;
import android.os.Bundle;
import android.app.Activity;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity implements OnItemSelectedListener, OnItemClickListener {
PluginScrollView mPluginScrollView;
View circleView;
ViewPager viewPager;
ViewPagerAdapter viewPagerAdapter;
ListtestList;
private TextView selectedTextView;
private CircleLayout circleMenu;
LayoutInflater mInflater;
@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_tab_scrollview_main);
TextView textView;
testList = new ArrayList();
for (int i = 0; i <3; i + +) {
if (i == 0) {
mInflater = getLayoutInflater ();
testList.add (mInflater.inflate (R.layout.activity_custom_circleimage_main, null));
circleView = mInflater.inflate (R.layout.activity_custom_circleimage_main, null);
circleMenu = (CircleLayout) circleView.findViewById (R.id.main_circle_layout);
selectedTextView = (TextView) circleView.findViewById (R.id.main_selected_textView);
}
else {
textView = new TextView (MainActivity.this);
textView.setText ("ViewPager ==>" + i);
testList.add (textView);
}
}
viewPager = (ViewPager) findViewById (R.id.viewpagerLayout);
viewPagerAdapter = new ViewPagerAdapter ();
viewPagerAdapter.setList (testList);
viewPager.setAdapter (viewPagerAdapter);
viewPager.setCurrentItem (0);
/ / MPluginScrollView = new PluginScrollView (this, viewPager, testList);
mPluginScrollView = (PluginScrollView) findViewById (R.id.horizontalScrollView);
mPluginScrollView.setTestList (testList);
mPluginScrollView.setViewPager (viewPager);
viewPager.setOnPageChangeListener (new OnPageChangeListener () {
@ Override
public void onPageSelected (int arg0) {
/ / TODO Auto-generated method stub
Log.d ("k", "onPageSelected -" + arg0);
mPluginScrollView.buttonSelected (arg0);
viewPager.setCurrentItem (arg0);
}
@ Override
public void onPageScrolled (int arg0, float arg1, int arg2) {
/ / TODO Auto-generated method stub
Log.d ("k", "onPageScrolled -" + arg0);
}
@ Override
public void onPageScrollStateChanged (int arg0) {
/ / TODO Auto-generated method stub
Log.d ("k", "onPageScrollStateChanged -" + arg0);
/ / Idle status has three 0, 1 is the increase in the taxi, the two goals loaded
}
});
circleMenu.setOnItemSelectedListener (this);
circleMenu.setOnItemClickListener (this);
selectedTextView.setText (((CircleImageView) circleMenu.getSelectedItem ()) getName ().);
}
@ Override
public boolean onCreateOptionsMenu (Menu menu) {
/ / Inflate the menu; this adds items to the action bar if it is present
.getMenuInflater () inflate (R.menu.main, menu);.
return true;
}
@ Override
public void onItemSelected (View view, int position, long id, String name) {
selectedTextView.setText (name);
}
@ Override
public void onItemClick (View view, int position, long id, String name) {
. Toast.makeText (. GetApplicationContext (), getResources () getString (R.string.start_app) + "" + name, Toast.LENGTH_SHORT) show ();
}
}
circleMenu.setOnItemSelectedListener (this);
circleMenu.setOnItemClickListener (this); After running these two events did not respond, please advise how to fix the god code.
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Their top!
No comments:
Post a Comment