Question
I am new to android and I am having problem viewing my view contents in view pager layout. the following is my actiivity and adapter
I am new to android and I am having problem viewing my view contents in view pager layout. the following is my actiivity and adapter togather on the same file and the the viewpager xml and the details.
my details.xml
android:useDefaultMargins="true" android:paddingTop="70dp">
my viewPager xml file has the following contents
my activity class has the following codes and also contain the adapter class and the code is as follows public class AddEdit extends AppCompatActivity
{
private static final int CONTACT_LOADER = 0; //
private Uri contactUri;
private SQLiteDatabase mDatabase; private Context mContext;
ViewPager mViewPager; pageViewAdapter1 slider;
List
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_edit); Toolbar tool=(Toolbar) findViewById(R.id.toolbar1); mViewPager=(ViewPager) findViewById(R.id.slide); slider=new pageViewAdapter1(this); mViewPager.setAdapter(slider); setSupportActionBar(tool); // load the contac // getSupportLoaderManager().initLoader( CONTACT_LOADER, null, this);
} @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater findMenuItems = getMenuInflater(); findMenuItems.inflate(R.menu.fragment_details_menu, menu); return super.onCreateOptionsMenu(menu); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_delete: Toast.makeText(AddEdit.this,"delete ",Toast.LENGTH_LONG).show(); break; case R.id.action_edit: finish(); break; } return super.onOptionsItemSelected(item); }
private ACursorWrapper queryInfo(String whereClause, String[] whereArgs){ mContext=getApplicationContext(); mDatabase = new AddressBookDatabaseHelper(mContext) .getWritableDatabase(); Cursor cursor = mDatabase.query( DatabaseDescription.Contact.TABLE_NAME, null, // columns - null selects all columns whereClause, whereArgs, null, // groupBy null, // having null // orderBy ); return new ACursorWrapper(cursor); }
public List
List
public Info getInfo(int id) {
ACursorWrapper cursor = queryInfo( DatabaseDescription.Contact._ID + " = ?", new String[] { id+"" } ); try { if (cursor.getCount() == 0) { return null; } cursor.moveToFirst(); return cursor.getInfo(); } finally { cursor.close(); } }
public class pageViewAdapter1 extends PagerAdapter { Context context; LayoutInflater mInflater; private TextView nameTextView; // displays contact's name private TextView phoneTextView; // displays contact's phone private TextView emailTextView; // displays contact's email private TextView streetTextView; // displays contact's street private TextView cityTextView; // displays contact's city private TextView stateTextView; // displays contact's state private TextView zipTextView; // displays contact's zip
public pageViewAdapter1(Context context) { this.context = context; }
@Override
public int getCount() { return informatn.size(); }
@Override public boolean isViewFromObject(View view, Object object) { return (view==(View)object); }
@Override public Object instantiateItem(ViewGroup container, int position) { mInflater=(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View item_view=mInflater.inflate(R.layout.detail,container,false);
// get the EditTexts nameTextView = (TextView) item_view.findViewById(R.id.nameTextView1); phoneTextView = (TextView) item_view.findViewById(R.id.phoneTextView1); emailTextView = (TextView) item_view.findViewById(R.id.emailTextView1); streetTextView = (TextView) item_view.findViewById(R.id.streetTextView1); cityTextView = (TextView) item_view.findViewById(R.id.cityTextView1); stateTextView = (TextView) item_view.findViewById(R.id.stateTextView1); zipTextView = (TextView) item_view.findViewById(R.id.zipTextView1);
informatn=getInfos();
nameTextView.setText(informatn.get(position).name); phoneTextView.setText(informatn.get(position).phone); emailTextView.setText(informatn.get(position).eamil); streetTextView.setText(informatn.get(position).street); cityTextView.setText(informatn.get(position).City); stateTextView.setText(informatn.get(position).state); zipTextView.setText(informatn.get(position).zip);
container.addView(item_view);
return item_view;
}
@Override public void destroyItem(ViewGroup container, int position, Object object) { container.removeView((FrameLayout)object); } }
}
could some one tell me why I don't see widgets in detail.xml after I inflated them.Please try to understand that I am just beginner trying to learn. thank you
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started