2017-01-03 7 views
0

私はxamarin.androidにかなり新しいです。私はスクロールビューでイメージビューを持っていますので、クリックして拡大したいと思います。ユーザーが画像をクリックするとフルスクリーンで表示されたフル画像をクリックして表示することができます。フルスクリーンで開くことができます。これはどのように行うのですか?フルスクリーンイメージビューの表示方法onlclick

iveいくつかの調査を行い、有用なスレッドを見つけることができませんでした..任意のヘルプは、事前に感謝するでしょう。

HERESに私のdetailactivityクラス

private ImageView mtimg0, mtimg1, mtimg2, mtimg3, mtimg4, mtimg5; 
protected override void OnCreate(Bundle savedInstanceState) 
{ 
     base.OnCreate(savedInstanceState); 
     SetContentView(Resource.Layout.detailLayout); 

     FindViews(); 


     Android.Content.Intent i = this.Intent; 
     string iname = i.Extras.GetString("MTNAME"); 
     int iimg0 = i.Extras.GetInt("IMG0"); 
     int iimg1 = i.Extras.GetInt("IMG1"); 
     int iimg2 = i.Extras.GetInt("IMG2"); 
     int iimg3 = i.Extras.GetInt("IMG3"); 
     int iimg4 = i.Extras.GetInt("IMG4"); 
     int iimg5 = i.Extras.GetInt("IMG5"); 

     mtimg0.SetImageResource(iimg0); 
     mtimg1.SetImageResource(iimg1); 
     mtimg2.SetImageResource(iimg2); 
     mtimg3.SetImageResource(iimg3); 
     mtimg4.SetImageResource(iimg4); 
     mtimg5.SetImageResource(iimg5); 
    } 

    private void FindViews() 
    { 
     tmtname = FindViewById<TextView>(Resource.Id.mtname); 
     mtimg0 = FindViewById<ImageView>(Resource.Id.mtimg00); 
     mtimg1 = FindViewById<ImageView>(Resource.Id.mtimg01); 
     mtimg2 = FindViewById<ImageView>(Resource.Id.mtimg02); 
     mtimg3 = FindViewById<ImageView>(Resource.Id.mtimg03); 
     mtimg4 = FindViewById<ImageView>(Resource.Id.mtimg04); 
     mtimg5 = FindViewById<ImageView>Resource.Id.mtimg05);    

    } 
} 

EDITED

ここで私は私のすべての画像

class MountainsData 
    { 
    public static List<Mountain> MountainList = new List<Mountain>() 
     { 
     new Mountain() 
      { 
       MtName = "ALTO PEAK", 
       Masl = 1332, 
       Difficulty = 6, 
       Island = 2, 
       MtImg00 = Resource.Drawable.altopeak, 
       MtImg01 = Resource.Drawable.altopeak1, 
       MtImg02 = Resource.Drawable.altopeak2, 
       MtImg03 = Resource.Drawable.altopeak3, 
       MtImg04 = Resource.Drawable.altopeak4, 
       Location = "ORMOC, LEYTE", 
       JumpOff ="Lake Danao National Park, Ormoc", 
       Description ="LLA: 11.1061 N, 124.7097 E, 1332 
      } 

、私の中に取得しています私のリストビュー内の項目の例ですリストビューアクティビティ..ここでは、各アイテムを自分の詳細アクティビティに渡しています...そして、詳細アクティビティでそれを受け取るために私はコードaboを使用しています(この質問では上記の最初のコードは、.. detailactivityクラスで)フルスクリーンで表示..私はImageViewのをクリックしたときに私がdetailactivity内で起こるしたいことはある

​​

ましたが、私はへの道を見つけるカント適切に文字列を渡し..事前にありがとう:D

+0

可能な複製を(http://stackoverflow.com/質問/ 22409920/enlarge-an-image-on-click) – Demitrian

+0

または、FullScreen Viewの新しいアクティビティを作成するだけです。インテントを持つ画像またはパスを新しいアクティビティに渡します。 – user1519979

+0

あなたのプロジェクトのカスタムソリューションが必要な場合は、あなたのアクティビティーから離れたくない場合は、断片に表示することもできます: –

答えて

0

これはDialogFragmentとソリューションです:

あなたfragment_dialog.axml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:minWidth="2000dp" 
    android:minHeight="2000dp"> 
    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:id="@+id/img" 
     android:src="@drawable/aaa" 
     android:scaleType="fitCenter"/> 
</LinearLayout> 

あなたMyDialogFragment.cs

public class MyDialogFragment : DialogFragment 
{ 
    private ImageView imgView; 
    static public MyDialogFragment newInstance() 
    { 
     MyDialogFragment f = new MyDialogFragment(); 
     return f; 
    } 

    public override void OnCreate(Bundle savedInstanceState) 
    { 
     base.OnCreate(savedInstanceState); 
     SetStyle(DialogFragmentStyle.NoTitle, Android.Resource.Style.ThemeBlackNoTitleBarFullScreen); 
    } 

    public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
    { 
     base.OnCreateView(inflater, container, savedInstanceState); 
     View v = inflater.Inflate(Resource.Layout.fragment_dialog, container, false); 

     imgView = v.FindViewById<ImageView>(Resource.Id.img); 
     //Get int and set it to the ImageView 
     int imgPassed = Arguments.GetInt("imgId"); 
     imgView.SetImageResource(imgPassed); 

     return v; 
    } 
} 

あなたItemSelectedからまたはクリックイベント

 FragmentTransaction ft = FragmentManager.BeginTransaction(); 
     DialogFragment newFragment = MyDialogFragment.newInstance(); 

     //Declare String and get the Id 
     string imgName = "bbb"; //Change with the name of the image you want to pass 
     int imgId = Resources.GetIdentifier(imgName, "drawable", PackageName); 

     //Pass it with the Bundle class 
     Bundle bundle = new Bundle(); 
     bundle.PutInt("imgId", imgId); 
     newFragment.Arguments = bundle; 

     //Show the Fragment 
     newFragment.Show(ft, "dialog"); 

編集:私はからデータを渡すことも可能な方法の一つとしてバンドルクラスを使用 断片への活動。私のためにうまく動作します。同じ結果は、単に別のアクティビティとインテントを使用している持っている

もう一つの方法は、あなたがここに必要なすべてを見つけることができます:[クリックでImageViewのを拡大する]のPassing Data Between Activities

+0

hello sir ben /あなたの答えに感謝します..それは多くの助けになりました..あなたは私にどのように活動から文字列を渡すことができますか? –

+0

@KeithJustine投稿を編集しましたが、それはあなたのために働くのであれば、質問に回答としてマークするようにしてください。私にもっと助けが必要な場合:-) –

+0

こんにちは、あなたの答えは非常に有用ですが、私はまだ文字列を渡す上で問題を抱えている..遅く返事、申し訳ありません。正しいデータ.. "int iimg5 = i.Extras.GetInt(" IMG5 ");"このコード行は、どのように私のリストビューから詳細アクティビティへの文字列の受け渡しです..ちょうど私がダイアログのフラグメントでそれを渡すことができますか? –

関連する問題