我正在研究android项目,我遇到一个问题,在列表视图下方的屏幕底部显示广告而不会导致任何重叠.
目前,如果列表视图中存在大量项目导致滚动,则广告应该显示在列表视图下方,但是当广告位于列表视图的顶部时,因此,用户可以'看看列表视图底部的内容.
下面是我的XML布局的副本
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="@color/black"
android:orientation="vertical" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView android:id="@+id/password_noRecords"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:text="There are currently\nno saved logins"
android:textSize="20dp"
android:textStyle="bold|italic"/>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</ListView>
<Button android:id="@+id/password_clearSearch"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/password_clear_search"
android:layout_alignParentBottom="true"
android:visibility="gone"/>
</LinearLayout>
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal"
ads:adUnitId="a14d6125d95c70b"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, 015d1884222bfe01"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我有很多不同的方法,将它全部放在相对布局中而不是具有另一个线性布局,没有对齐父底部= true但是它位于列表视图的顶部,重叠列表视图顶部的任何内容.
感谢您的任何帮助,您可以提供.
在Google宣布基于IntelliJ的Android Studio之后,我想尝试一下,但我遇到了问题.它安装得很好,并且在安装过程中成功找到了JDK,但是当我尝试启动它时没有任何反应.没有错误,没有闪屏没有什么.
其他人遇到过这个问题吗?
感谢您的任何帮助,您可以提供.
我目前正在开发一个C#WPF应用程序,我正在尝试添加一个图像,然后在每个列表项中添加一些文本.
我有绑定工作的文本,但图像不显示.
以下是我的XAML:
<Window x:Class="ServerAdministrator.FtpDirectoryListing"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ServerAdministrator"
Title="FTP Directory Listing" Height="391" Width="599">
<Grid>
<StatusBar Height="30" Margin="0,322,0,0" Name="statusBar1" VerticalAlignment="Top" />
<ToolBar Height="26" Name="toolBar1" VerticalAlignment="Top" />
<TextBox Height="23" HorizontalAlignment="Left" Margin="12,32,0,0" Name="textBox1" VerticalAlignment="Top" Width="517" />
<ListBox x:Name="lstDirecotryListing" Height="233" HorizontalAlignment="Left" Margin="12,61,0,0" VerticalAlignment="Top" Width="553">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type local:DirectoryListing}">
<StackPanel>
<TextBlock Margin="3" Text="{Binding path}" />
<ContentControl Margin="3" Content="{Binding image}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
下面是我的DirectoryListing类
class DirectoryListing
{
public string path {get; set;}
public Image image{get; set;}
public DirectoryListing(Image imgage, String path)
{ …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Android项目,我需要检查空格键何时被按下sos我可以执行某个功能.
问题是,它正在模拟器上工作,但不在我的实际设备上.我想这可能是因为我的模拟器使用的是物理键盘,而不是屏幕上的虚拟键盘,但在实际设备上进行测试时,它使用的是虚拟键盘.
我正在尝试调度keyevent
@Override
public boolean dispatchKeyEvent(KeyEvent event)
{
if (event.getKeyCode() == KeyEvent.KEYCODE_SPACE
&& event.getAction() == KeyEvent.ACTION_UP)
{
QueryEditor queryEditor = (QueryEditor)getSupportFragmentManager().findFragmentById(R.id.fragment_queryEditor);
queryEditor.formatQueryText();
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
我也试过按键
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK)
{
disconnectDatabase();
}
else if (keyCode == KeyEvent.KEYCODE_DEL)
{
QueryEditor queryEditor = (QueryEditor)getSupportFragmentManager().findFragmentById(R.id.fragment_queryEditor);
queryEditor.formatQueryText();
}
return super.onKeyDown(keyCode, event);
}
Run Code Online (Sandbox Code Playgroud)
除非按下后退按钮但我需要空格键来触发事件,否则这些都不会被触发.
感谢您的任何帮助,您可以提供.
UPDATE
下面是我如何创建QueryEditor Fragment并创建事件处理程序的代码
@Override
public void onActivityCreated(Bundle savedInstanceState)
{
super.onActivityCreated(savedInstanceState);
iQueryEditor = (IQueryEditor)this;
iErrorHandler = (IErrorHandler)this;
txtQueryEditor = (EditText)getActivity().findViewById(R.id.query_txtQueryEditor); …Run Code Online (Sandbox Code Playgroud) 我正在开发一个Android项目,我正在尝试从https://github.com/PhilJay/MPAndroidChart实现名为MPAndroidChart的库.
我试图在一个片段中实现它,但我一直收到错误,我不明白为什么.
以下是我的活动.
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
Fragment chartFragment = new ChartFragment();
transaction.replace(R.id.fragmentContainer, chartFragment);
transaction.commit();
}
}
Run Code Online (Sandbox Code Playgroud)
下面是我的活动布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<FrameLayout android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
下面是我的Fragment类
public class ChartFragment extends Fragment
{
private LineChart mChart;
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.graph, container, false);
return v;
}
}
Run Code Online (Sandbox Code Playgroud)
下面是片段的布局
<?xml version="1.0" …Run Code Online (Sandbox Code Playgroud) 我正在开发一个 Android 项目,并且正在创建一个自定义列表视图。列表视图包含多个文本视图,我正在为我的文本视图创建一个样式,因此我不必一遍又一遍地重复相同的样式。
下面是我的布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/txtFirstOccurred"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
style="@style/CrashGroup"/>
<TextView android:id="@+id/txtLastOccurred"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
style="@style/CrashGroup"/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
以下是我的文本视图的样式
<style name="CrashGroup">
<item name="android:singleLine">false</item>
<item name="android:textSize">@android:style/TextAppearance.Small</item>
<item name="android:gravity">center_vertical</item>
</style>
Run Code Online (Sandbox Code Playgroud)
下面是我如何扩展 XML 以显示在列表视图上。
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
try
{
convertView = LayoutInflater.from(getContext()).inflate(R.layout.android_crash_group_layout, null);
TextView txtFirstOccurred = (TextView)convertView.findViewById(R.id.txtFirstOccurred);
txtFirstOccurred.setText(getItem(position).getFirstOccurred());
TextView txtLastOccurred = (TextView)convertView.findViewById(R.id.txtLastOccurred);
txtLastOccurred.setText(getItem(position).getLastOccurred());
return convertView;
}
catch (Exception ex)
{
Log.e(TAG, ex.toString());
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
我收到的错误是:
进程:com.BoardiesITSolutions.CritiMonApp,PID:1451 java.lang.NullPointerException:尝试在 …
android listview android-listview layout-inflater inflate-exception
我正在开发一个测试应用程序,以了解如何使用SSH隧道连接到C++中的MySQL数据库.
我正在使用libssh2库,我正在使用https://www.libssh2.org/examples/direct_tcpip.html中的示例,但我不能100%确定这是否正确使用.
我几乎复制了这个例子但是当我在socket上连接到MySQL时,MySQL会抛出:
Errro 2013(HY000):在"读取通信包"时丢失了与mysql服务器的连接,系统错误:0
当我使用mysql -uroot -p -P2222连接到mysql时,我的应用程序使用以下内容读取通道上的数据:
int len = libssh2_channel_read(channel, buf, sizeof(len));
并且buf包含SSH-2.0-然后将其写入转发套接字,如下所示:
wr = 0;
while (wr < len)
{
i = send(forward_socket, buf + wr, len - wr, 0);
if (i <= 0)
{
perror("write");
return EXIT_FAILURE;
}
wr += i;
}
Run Code Online (Sandbox Code Playgroud)
发送完成后,我立即得到mysql错误.我认为这是因为我发送SSH-2.0- MySQL MySQL并不期望它关闭连接,但我看不出有什么问题,我无法确定libssh2 direct_tcpip是否正确要使用的东西.
我正在开发一个C++项目,我使用libcurl通过SMTP发送电子邮件.代码几乎适用于小内容,但是,对于较大的电子邮件,它会引发写入访问冲突,我看不出任何原因.
以下是我使用curl函数发送邮件的方式:
curl = curl_easy_init();
//curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1);
if (curl)
{
if (this->useVerboseOutput)
{
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
}
curl_easy_setopt(curl, CURLOPT_URL, smtpAddress.c_str());
if (this->useTLS)
{
curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
}
if (this->useAuthentication)
{
if (this->username.empty() || this->password.empty())
{
throw logic_error("SMTP username or password has not been set but authentication is enabled");
}
curl_easy_setopt(curl, CURLOPT_USERNAME, this->username.c_str());
curl_easy_setopt(curl, CURLOPT_PASSWORD, this->password.c_str());
}
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, this->fromAddress.c_str());
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
curl_easy_setopt(curl, CURLOPT_READDATA, this);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, &EmailSender::invoke_write_data);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
//Send the message
res = curl_easy_perform(curl);
Run Code Online (Sandbox Code Playgroud)
下面是read函数回调
size_t …Run Code Online (Sandbox Code Playgroud) 我正在开发一个android应用程序,并集成了firebase和firebase crashlytics SDK。
我想允许用户禁用崩溃报告(以确保GDPR合规性-我认为崩溃报告与GDPR相关),因此需要一种方法,使用户能够通过应用设置禁用它。
我在https://firebase.google.com/docs/crash/disable-sdk上找到了文档,但是当我尝试该行时:
FirebaseCrash.setCrashCollectionEnabled(true);
Run Code Online (Sandbox Code Playgroud)
Android Studio给我错误 cannot resolve symbol 'FirebaseCrash'
这需要在应用程序的运行时以编程方式完成。
我正在使用 Electron 和 ReactJS 开发一个新项目。该项目在开发模式下运行良好,但我正在尝试为 Windows 创建一个安装程序,但无论我尝试什么以及在 Google 上找到什么,都没有任何效果。我只是得到一个空白的白色屏幕。
下面是我的 pacakge.json
{
"name": "MyApp",
"description": "My App Description",
"version": "0.1.2",
"private": true,
"homepage": "./",
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"@types/jest": "^26.0.14",
"@types/node": "^14.11.2",
"@types/react": "^16.9.50",
"@types/react-dom": "^16.9.8",
"bootstrap": "^4.5.2",
"electron-is-dev": "^1.2.0",
"electron-settings": "^4.0.2",
"electron-squirrel-startup": "^1.0.0",
"react": "^16.13.1",
"react-bootstrap": "^1.3.0",
"react-dom": "^16.13.1",
"react-icons": "^3.11.0",
"react-json-pretty": "^2.2.0",
"react-scripts": "3.4.3",
"react-tooltip": "^4.2.10",
"typescript": "^4.0.3"
},
"main": "src/electron-starter.js",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts …Run Code Online (Sandbox Code Playgroud)