0

我在我的应用程序中使用了viewpaer!我需要在其中一个屏幕上插入手风琴视图的位置!

我找到了我需要使用手风琴的代码,但不知道如何在我的 Activity.java 中输入代码!

对于我使用 viewpager 的模型来说很复杂。

我想知道如何在我的活动中输入手风琴代码。

这里是我的 DiferencialActivity.java 的代码:

package com.example.resina.e.marcon;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class DiferencialActivity extends Fragment {

    Button button1,button2;
    LinearLayout panel1,panel2;

    public static Fragment newInstance(Context context) {
        DiferencialActivity f = new DiferencialActivity();

        return f;


    }

    @Override
    public View onCreateView(LayoutInflater inflater, 
            ViewGroup container,Bundle savedInstanceState) {
        ViewGroup root = (ViewGroup) inflater.inflate(R.layout.diferencial_layout, null);

        return root;



    }



}

这是您需要输入到我的 DiferencialActivity 中的代码,因此她可以解释为此活动定义的按钮的布局:

package com.example.resina.e.marcon;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;

public class teste extends Activity
{
      Button button1,button2;
      LinearLayout panel1,panel2;


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.diferencial_layout);

        button1 = (Button)findViewById(R.id.button1);
        button2 = (Button)findViewById(R.id.button2);

        button1.setOnClickListener(buttonClickListener);
        button2.setOnClickListener(buttonClickListener);


        panel1 = (LinearLayout)findViewById(R.id.panel1);
        panel2 = (LinearLayout)findViewById(R.id.panel2);

        /*We make both the panels, by default, invisible to user
        and make them appear on button click event in follwing manner*/

        panel1.setVisibility(View.GONE);
        panel2.setVisibility(View.GONE);



    }


    public OnClickListener buttonClickListener = new OnClickListener()
    {

            @Override
            public void onClick(View v)
            {
                  Button ClickedButton = (Button)v;

                  if(ClickedButton.getId()== button1.getId())
                  {
                            panel1.setVisibility(View.VISIBLE);
                          panel2.setVisibility(View.GONE);
                  }
                  else if(ClickedButton.getId()== button2.getId())
                  {
                        panel1.setVisibility(View.GONE);
                    panel2.setVisibility(View.VISIBLE);
                  }
            }
      };


}

如何在我的 DiferencialActivity.java 中插入此代码?

4

0 回答 0