Click here to Skip to main content
15,890,506 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have home activity which have tab control and on first tab the main activity is shown. On main tab i have buttons which will redirect to another activity.
and cannot redirect to another activity.

What I have tried:

package mobileofflineapp.gopalchudal.mobileofflineapp;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class Main1 extends Fragment {
ImageView saving, loan;

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

saving = (ImageView) container.findViewById(R.id.imgSavingCollection);
loan = (ImageView) container.findViewById(R.id.imgLoanCollection);

saving.setOnClickListener((View.OnClickListener) container);
loan.setOnClickListener((View.OnClickListener) container);

View v = inflater.inflate(R.layout.activity_main1, container, false);
return v;
}

public void onClick(View v) {
switch (v.getId()) {
case R.id.imgSavingCollection:
Intent savingactivity = new Intent(v.getContext(), SavingCollection.class);
startActivity(savingactivity);
break;
case R.id.imgLoanCollection:
Intent laonactivity = new Intent(v.getContext(), LoanCollection.class);
startActivity(laonactivity);
break;
}
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900