PoopubWindow,能用showAsDropDown,就是用不了showAtLocation,(如图)

alex001001001 2015-10-02 01:59:05
就是设置不了Gravity,真是日了狗了,不知道是倒入类错了,还是其他其他原因


完整代码如下:
错的在倒数几行

package com.example.zhuwen.model_popubwindow;

import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.widget.EditText;
import android.view.View;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.view.View.OnClickListener;
import android.widget.Toast;

public class MainActivity extends Activity{

private PopupWindow popupWindow;
private View contentView;
private TextView tx_pop;
private TextView tx_test;
private EditText ed_test;
int width=0,height=0;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

tx_pop = (TextView)findViewById(R.id.tx_pop);
tx_test = (TextView)findViewById(R.id.tx_test);
ed_test = (EditText)findViewById(R.id.ed_test);

//get the width and height of screen
final DisplayMetrics metric = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metric);
width = metric.widthPixels/2;
height = metric.heightPixels/2;

tx_test.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getApplicationContext(),"Can Touch",
Toast.LENGTH_SHORT).show();
}
});

tx_pop.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
get_pop();
}
});

}

public void get_pop() {

contentView = getLayoutInflater().inflate(R.layout.pop_win, null);
popupWindow = new PopupWindow(contentView, 300,
200);
popupWindow.setContentView(contentView);
//.setBackgroundDrawable(getResources().getDrawable(R.drawable.search_label_click));
//.setBackgroundColor(Color.parseColor("#F5F5DC"));
//.setBackgroundColor(Color.GRAY);
popupWindow.setBackgroundDrawable(getResources().getDrawable(R.drawable.test));
//set "true" ,then you can enter something
//set "true",a popwin will disappear when you touch the outside of the popwin
popupWindow.setFocusable(true);
//decided the location of a popwin
popupWindow.showAtLocation(R.id.tx_pop,Gravity.LEFT, 0, 0);
//the command to close a popwin
//popupWindow.dismiss();

}
}
...全文
186 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
alex001001001 2015-10-03
  • 打赏
  • 举报
回复
引用 1 楼 阿飞__的回复:
是导不了这个类?试一下自己手动导包吧
倒好了
alex001001001 2015-10-03
  • 打赏
  • 举报
回复
哪个类,你倒是给个详细点的解释呀
阿飞__ 2015-10-02
  • 打赏
  • 举报
回复
是导不了这个类?试一下自己手动导包吧
企业智慧中台规划与建设总体方案是一个针对企业数字化转型需求而设计的综合性IT解决方案。该方案旨在构建一个集中、高效和灵活的中台架构,通过整合企业内外部的数据资源、业务流程和应用服务,为企业提供一个统一的数字化运营平台。在当前的商业环境下,企业面临着激烈的市场竞争和不断变化的客户需求。为了应对这些挑战,企业需要快速响应市场变化,提高运营效率,降低成本,并实现持续创新。因此,企业智慧中台的规划和建设成为了关键任务。该方案的核心思想是将企业的业务逻辑、数据管理和技术创新紧密结合起来,形成一个高度集成的智慧中台系统。通过构建标准化的数据模型和接口,实现数据的一致性和可访问性,同时提供丰富的数据分析和挖掘工具,帮助企业发现潜在的商业价值和机会。此外,该方案还注重用户体验和业务敏捷性。通过构建灵活的应用开发框架和API接口,支持快速的业务迭代和定制化需求,满足不同部门和角色的个性化需求。同时,通过智能化的自动化流程和决策支持系统,提高企业的决策效率和准确性。总之,企业智慧中台规划与建设总体方案是一个全面而深入的IT解决方案,旨在帮助企业实现数字化转型,提升竞争力和创新能力。通过构建集中、高效和灵活

80,350

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧