目前,Im公司正在试验安乐施。 而不是形象 我的意见使用了网站概览。 这些网址不能被点击,因此可以把彩色带走或右边。 但是,在长点上,网站概览应当被点击。 我的法典直到第2.2版。 现在,我有3个测试装置,该代码在长点后失效。 《刑法》如下。
It goes wrong here
customGallery g = (customGallery) findViewById(R.id.gallery);
g.setAdapter(new ImageAdapter(this));
// ZOOM FUNCTION !
//Detect longclicks on the gallery if the user preforms a longclick we check if view is clickable (clickable means we can zoom in on the webview)
g.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView parent, View v, int position, long id) {
//IT GOES WRONG RIGHT HERE
try{
if(v.isClickable()){
Toast.makeText(ImageGalleryActivity.this, "Zoom disabled", Toast.LENGTH_SHORT).show();
v.setClickable(false);
iiielse{
v.setClickable(true);
Toast.makeText(ImageGalleryActivity.this, "Zoom enabled", Toast.LENGTH_SHORT).show();
iii
iiicatch (Exception e){
Log.i("Exception", String.format("%s", e));
Toast.makeText(ImageGalleryActivity.this, "NULLPNTR", Toast.LENGTH_SHORT).show();
iii
return true;
iii
iii);
iii
这里是活动的全部法典......
public class ImageGalleryActivity extends Activity {
private WebView web;
public int screenWidth;
public int screenHeight;’
public View vx;
//ArrayList needed to quickly store the images we get from the AssetManager
ArrayList <String> imgID = new ArrayList <String>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Asset Manager needed to collect all the files in specific folders of assets
final AssetManager assetManager = getAssets();
Display display = getWindowManager().getDefaultDisplay();
screenWidth = display.getWidth();
screenHeight = display.getHeight();
Log.i("Intial Height", String.format("%d", screenHeight));
Log.i("Intial Width", String.format("%d", screenWidth));
//Try collecting all the images
try{
String [] filelist = assetManager.list("book1");
if (filelist == null){
//TODO errorCatching
iiielse{
for (int i = 0; i<filelist.length; i++){
String fileName = filelist[i];
Log.i("THE FILENAMES", fileName);
//Add the images to the ArrayList (stringtype)
imgID.add(fileName);
iii
iii
iiicatch (IOException e){
iii
setContentView(R.layout.main);
customGallery g = (customGallery) findViewById(R.id.gallery);
g.setAdapter(new ImageAdapter(this));
// ZOOM FUNCTION !
//Detect longclicks on the gallery if the user preforms a longclick we check if view is clickable (clickable means we can zoom in on the webview)
g.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView parent, View v, int position, long id) {
//IT GOES WRONG RIGHT HERE
try{
if(v.isClickable()){
Toast.makeText(ImageGalleryActivity.this, "Zoom disabled", Toast.LENGTH_SHORT).show();
v.setClickable(false);
iiielse{
v.setClickable(true);
Toast.makeText(ImageGalleryActivity.this, "Zoom enabled", Toast.LENGTH_SHORT).show();
iii
iiicatch (Exception e){
Log.i("Exception", String.format("%s", e));
Toast.makeText(ImageGalleryActivity.this, "NULLPNTR", Toast.LENGTH_SHORT).show();
iii
return true;
iii
iii);
iii
//Create imageAdapter class...
public class ImageAdapter extends BaseAdapter{
int imagebackground;
private Context mContext;
public ImageAdapter(Context c){
mContext = c;
TypedArray a = obtainStyledAttributes(R.styleable.gallery);
imagebackground = a.getResourceId(R.styleable.gallery_android_galleryItemBackground, 0);
a.recycle();
iii
public int getCount(){
return imgID.size();
iii
public Object getItem(int position){
return position;
iii
public long getItemId(int position){
return position;
iii
public View getView(int position, View convertView, ViewGroup parent){
web = new WebView(mContext);
String currImg = imgID.get(position);
Log.i("Drawable", String.format("%s", imgID.get(position)));
String stringScreenWidth = String.format("%d", screenWidth-200);
Log.i("Current ScreenWidth", String.format("%d", screenWidth));
Log.i("Should be", stringScreenWidth);
web.loadDataWithBaseURL("file:///android_asset/book1/", "<html><meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=10 minimum-scale=1"><body style= width:"+screenWidth+"px;margin:0;padding:0;min-width:100%; ><image style= width:"+screenWidth+"px; src= "+currImg+" /><body></html>", "text/html", "UTF-8", null);
//web.getSettings().setBuiltInZoomControls(true);
web.setVerticalScrollBarEnabled(false);
web.setHorizontalScrollBarEnabled(false);
web.setMinimumHeight(1024);
web.getSettings().setSupportZoom( true ); //Modify this
web.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);//
web.setLayoutParams( new customGallery.LayoutParams(WindowManager.LayoutParams.FILL_PARENT, WindowManager.LayoutParams.FILL_PARENT));
web.setClickable(false);
web.setFocusable(false);
web.setLongClickable(true);
return web;
iii
iii
iii