Я использую SwipeView Джейсона Фрая, он использует его для просмотра изображений, но я пытаюсь заменить его макетом.
на данный момент это работает, если я заменю ImageView на TextView, но как бы я заменил ImageView на макет
любая помощь приветствуется спасибо
пакет com.example;
import android.graphics.Typeface;
import android.text.Layout;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.example.R;
import uk.co.jasonfry.android.tools.ui.PageControl;
import uk.co.jasonfry.android.tools.ui.SwipeView;
import uk.co.jasonfry.android.tools.ui.SwipeView.OnPageChangedListener;
import android.app.Activity;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.ImageView;
public class MyActivity extends Activity
{
SwipeView mSwipeView;
LinearLayout ll;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ll = new LinearLayout(this);
ll = loadLayout();
PageControl mPageControl = (PageControl) findViewById(R.id.page_control);
mSwipeView = (SwipeView) findViewById(R.id.swipe_view);
//loadImages();
for(int i=0; i<4;i++)
{
mSwipeView.addView(new FrameLayout(this));
}
TextView i0 = new TextView(this);
TextView i1 = new TextView(this);
i0.setText("page 1");
i1.setText("page 2");
((FrameLayout) mSwipeView.getChildContainer().getChildAt(0)).addView(ll);
((FrameLayout) mSwipeView.getChildContainer().getChildAt(1)).addView(ll);
SwipeImageLoader mSwipeImageLoader = new SwipeImageLoader();
mSwipeView.setOnPageChangedListener(mSwipeImageLoader);
mSwipeView.setPageControl(mPageControl);
}
private class SwipeImageLoader implements OnPageChangedListener
{
public void onPageChanged(int oldPage, int newPage)
{
if(newPage>oldPage)//going forwards
{
if(newPage != (mSwipeView.getPageCount()-1))//if at the end, don't load one page after the end
{
TextView v = new TextView(MyActivity.this);
v.setText("page :"+(newPage+1));
((FrameLayout) mSwipeView.getChildContainer().getChildAt(newPage+1)).addView(ll);
}
if(oldPage!=0)//if at the beginning, don't destroy one before the beginning
{
((FrameLayout) mSwipeView.getChildContainer().getChildAt(oldPage-1)).removeAllViews();
}
}
else //going backwards
{
if(newPage!=0)//if at the beginning, don't load one before the beginning
{
TextView v = new TextView(MyActivity.this);
v.setText("page :"+(newPage+1));
((FrameLayout) mSwipeView.getChildContainer().getChildAt(newPage-1)).addView(ll);
}
if(oldPage != (mSwipeView.getPageCount()-1))//if at the end, don't destroy one page after the end
{
((FrameLayout) mSwipeView.getChildContainer().getChildAt(oldPage+1)).removeAllViews();
}
}
}
}
private LinearLayout loadLayout()
{
//logo
ImageView logo = new ImageView(this);
logo.setImageResource(R.drawable.image001);
logo.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
// espace
TextView espace = new TextView(this);
espace.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
espace.setText(" ");
// wrap prest
LinearLayout wprest = new LinearLayout(this);
//Prestation
TextView txt_pres = new TextView(this);
txt_pres.setText(" Prestation n° ");
txt_pres.setTextColor(R.color.black);
// plaid
TextView plaid = new TextView(this);
plaid.setTextColor(R.color.black);
plaid.setTypeface(null, Typeface.BOLD);
plaid.setText("4558");
// -
TextView tiret = new TextView(this);
tiret.setTextColor(R.color.black);
tiret.setTypeface(null, Typeface.BOLD);
tiret.setText(" - ");
// plaid
TextView platyp = new TextView(this);
platyp.setTextColor(R.color.black);
platyp.setTypeface(null, Typeface.BOLD);
platyp.setText("ECHANGE");
wprest.addView(txt_pres);
wprest.addView(plaid);
wprest.addView(tiret);
wprest.addView(platyp);
LinearLayout ll = new LinearLayout(this);
ll.setBackgroundResource(R.color.white);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));
ll.addView(logo);
ll.addView(espace);
ll.addView(wprest);
return ll;
}
}