Could anyone point out the missing or incorrect line of code in my program, This is the code I'm working with. Btw thanks in advance for those who will help. This is the line of code in which the error 'Method call expected' is always popping.
View v = layoutInflater.inflate(layouts(position),container,false);
You can see the full code below.
import android.content.Context;
import android.content.Intent;
import android.support.v4.view.PagerAdapter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class MainActivity extends AppCompatActivity {
private Viewpager viewpager;
private Intromanager intromanager;
private int[] layouts;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
intromanager = new Intromanager(this);
if(!intromanager.Check())
{
intromanager.setFirst(false);
Intent i = new Intent(MainActivity.this, Main2Activity.class);
startActivity(i);
finish();
}
setContentView(R.layout.activity_main);
layouts = new int[]{R.layout.activity_screen_1,R.layout.activity_screen_2,R.layout.activity_screen_3};
}
public class ViewPagerAdapter extends PagerAdapter
{
private LayoutInflater layoutInflater;
@Override
public Object instantiateItem(ViewGroup container, int position) {
layoutInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = layoutInflater.inflate(layouts(position),container,false);
container.addView(v);
return v;
}
@Override
public int getCount() {
return layouts.length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view==object;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
View v =(View)object;
container.removeView(v);
}
}
}