Android 缩放图表
我需要为从网络检索的图形实现缩放功能。这些图表来自 php web 服务器,那么如何对这些图表实现缩放功能。任何人都可以帮助我解决这个问题。这是我用于从网络检索图形的 java 类代码。
localPalladium1YButton.setOnClickListener( new View.OnClickListener() {
public void onClick(View view)
{
localPalladium1DButton.setBackgroundResource(R.drawable.onedicon);
localPalladium5DButton.setBackgroundResource(R.drawable.fived);
localPalladium1MButton.setBackgroundResource(R.drawable.whitem);
localPalladium1YButton.setBackgroundResource(R.drawable.yover);
android.view.View.OnClickListener getImgListener = null;
localPalladium1YButton.setOnClickListener(getImgListener);
Bitmap palladiumBitmap3=fetchImage( PalladiumImageUrl4.trim() );
localPalladiumImageView.setImageBitmap( palladiumBitmap3 );
mSoundManager.playSound(1);
}
});
..................................
..................................
..................................
Bitmap bmImg;
void downloadFile(String fileUrl){
URL myFileUrl =null;
try {
myFileUrl= new URL(fileUrl);
}
catch (MalformedURLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
String url1 = "my url";
URL url = new URL(url1);
URLConnection conn = url.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
BitmapFactory.Options bf = new BitmapFactory.Options();
Bitmap bm = BitmapFactory.decodeStream(bis);
ImageView localGoldImageView = null;
localGoldImageView.setImageBitmap(bm);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Bitmap fetchImage( String urlstr )
{
try
{
URL url;
url = new URL( urlstr );
HttpURLConnection c = ( HttpURLConnection ) url.openConnection();
c.setDoInput( true );
c.connect();
InputStream is = c.getInputStream();
Bitmap img;
img = BitmapFactory.decodeStream( is );
return img;
}
catch ( MalformedURLException e )
{
Log.d( "RemoteImageHandler", "fetchImage passed invalid URL: " + urlstr );
e.printStackTrace();
}
catch ( IOException e )
{
Log.d( "RemoteImageHandler", "fetchImage IO exception: " + e );
e.printStackTrace();
}
return null;
}
谢谢,
穆拉里。
I need to implement zoom functionality for graphs which are retrieving from web. These graphs are from php web-server so how to implement zooming functionality to these graphs. Any one can help me to come out from this issue. This is my java class code for retriving graphs from web.
localPalladium1YButton.setOnClickListener( new View.OnClickListener() {
public void onClick(View view)
{
localPalladium1DButton.setBackgroundResource(R.drawable.onedicon);
localPalladium5DButton.setBackgroundResource(R.drawable.fived);
localPalladium1MButton.setBackgroundResource(R.drawable.whitem);
localPalladium1YButton.setBackgroundResource(R.drawable.yover);
android.view.View.OnClickListener getImgListener = null;
localPalladium1YButton.setOnClickListener(getImgListener);
Bitmap palladiumBitmap3=fetchImage( PalladiumImageUrl4.trim() );
localPalladiumImageView.setImageBitmap( palladiumBitmap3 );
mSoundManager.playSound(1);
}
});
..................................
..................................
..................................
Bitmap bmImg;
void downloadFile(String fileUrl){
URL myFileUrl =null;
try {
myFileUrl= new URL(fileUrl);
}
catch (MalformedURLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
String url1 = "my url";
URL url = new URL(url1);
URLConnection conn = url.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
BitmapFactory.Options bf = new BitmapFactory.Options();
Bitmap bm = BitmapFactory.decodeStream(bis);
ImageView localGoldImageView = null;
localGoldImageView.setImageBitmap(bm);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Bitmap fetchImage( String urlstr )
{
try
{
URL url;
url = new URL( urlstr );
HttpURLConnection c = ( HttpURLConnection ) url.openConnection();
c.setDoInput( true );
c.connect();
InputStream is = c.getInputStream();
Bitmap img;
img = BitmapFactory.decodeStream( is );
return img;
}
catch ( MalformedURLException e )
{
Log.d( "RemoteImageHandler", "fetchImage passed invalid URL: " + urlstr );
e.printStackTrace();
}
catch ( IOException e )
{
Log.d( "RemoteImageHandler", "fetchImage IO exception: " + e );
e.printStackTrace();
}
return null;
}
Thanks,
Murali.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看看 http://code.google.com/p/android-pinch/:它有使用捏合来实现缩放的代码。
Take a look at http://code.google.com/p/android-pinch/: it has code to implement zooming using pinch.