2016-02-07 35 views
0

下面一段代码我尝试设置一个ImageView灵活:Xamarin工作室 - ImageView的

var FindImage ="@drawable/Tabulator_E1_" +P2.ToString(); 
var imageView = FindViewById<ImageView> (Resource.Id.imageView1); 
imageView.SetImageBitmap (FindImage); 

在我@drawable我有几个位图,如Tabulator_E1_1Tabulator_E1_2等 可惜SetImageBitmap并不需要一个字符串。我正在寻找一种方法来做到这一点。

回答

0

使用BitmapFactory.DecodeFile()从字符串路径

var imageView = FindViewById<ImageView> (Resource.Id.imageView1); 
var bitmap = BitmapFactory.DecodeFile(bitmap_path); 
imageView.SetImageBitmap (bitmap); 
+0

THX杰森加载一个位图,几乎没有。不幸的是,imageView现在没有设置。难道是“@drawable”(“Resources”下的地图不正确? – HB1963